Wufoo ile kimlik doğrulama sorunu

1 Cevap

Ben Wufoo API documentation ile okumak içeri giriş ve ben çalışmak için authenication alabilirsiniz eğer sadece gösterecektir yönetici sadece bölümleri ile Wufoo form kurmak, ama ne zaman Ben kimlik doğrulaması sonra formu erişmeye çalıştığınızda, ben kimlik doğrulaması gerektiğini söylüyor. Bu şimdiye kadar (subdomain, api anahtar & form id değişti) ne olduğunu

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$curl1 = curl_init('http://fishbowl.wufoo.com/api/v3/users.xml');
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl1, CURLOPT_USERPWD, 'AOI6-LFKL-VM1Q-IEX9:footastic');
curl_setopt($curl1, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl1, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl1, CURLOPT_USERAGENT, 'Wufoo Sample Code');

$response = curl_exec($curl1);
$resultStatus = curl_getinfo($curl1);

if($resultStatus['http_code'] == 200) {
    echo 'başarı!<br>';
} else {
    echo 'Call Failed '.print_r($resultStatus);
}

$curl2 = curl_init("http://fishbowl.wufoo.com/api/v3/forms/w7x1p5/entries.json"); 
curl_setopt($curl2, CURLOPT_HEADER, 0);
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl2);
curl_close ($curl2);
echo $response;

curl_close($curl1);

?>

Ben $curl1 önce ya ben $curl2, benim ekranda aynı mesajı alıyorum çağırdıktan sonra kapatırsanız farketmez:

başarı!

You must authenticate to get at the goodies.

ve ben API, alt alan ve form kimliği tüm doğru olduğunu biliyorum.

Ve son bir ikramiye bir soru ... Ben Ajax kullanmak yerine tüm bu yapabilirim? - Ben formunu gösteren bu sayfa zaten API önemli olmamalı açığa, yönetici erişimi sınırlı olacaktır.

1 Cevap

Tamam bazı etrafında kazma yaptım.

Here's the thing, you need to authenticate for every call you want to make to the API. I noticed that in the URL that you used (http://fishbowl.wufoo.com/api/v3/users.xml) , you used http but the API requires you to use https. You will only get that You must authenticate to get at the goodies. message if you attempt to access through the normal HTTP protocol.

Yani ikinci çağrı için, tekrar tekrar kimlik doğrulaması gerekir.

Sizin sonra kod gibi görünmelidir:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$curl1 = curl_init('https://fishbowl.wufoo.com/api/v3/users.xml');
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl1, CURLOPT_USERPWD, 'AOI6-LFKL-VM1Q-IEX9:footastic');
curl_setopt($curl1, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl1, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl1, CURLOPT_USERAGENT, 'Wufoo Sample Code');

$response = curl_exec($curl1);
$resultStatus = curl_getinfo($curl1);

if($resultStatus['http_code'] == 200) {
    echo 'success!<br>';
} else {
    echo 'Call Failed '.print_r($resultStatus);
}

$curl2 = curl_init("https://fishbowl.wufoo.com/api/v3/forms/w7x1p5/entries.json"); 
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl2, CURLOPT_USERPWD, 'AOI6-LFKL-VM1Q-IEX9:footastic');
curl_setopt($curl2, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl2, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl2, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl2, CURLOPT_USERAGENT, 'Wufoo Sample Code');
$response = curl_exec($curl2);
curl_close ($curl2);
echo $response;

curl_close($curl2);

?>

Wufoo (çapraz etki AJAX istekleri için izin) JSONP geri çağrıları desteklemediği için AJAX yapılıyor tüm bunlar hakkında Sorunuza gelince, o şu anda mümkün değil. AJAX bu işlevselliği fiş istiyorsanız (Ben okuma bahsettiğimi bilmiyorsanız this other SO question) Ancak, yerel sunucu üzerinde PHP komut dosyası için bir AJAX arama yapabilirsiniz. PHP komut dosyası Wufoo kimlik doğrulaması, yukarıdaki gibi bir şey yapacağız.