UPDATE: I've found that this issue is related to my hosting setup somehow. The code is hosted on a DV server by Media Temple, however I placed the exact same code on a GS Media Temple server and it worked as expected. So any ideas as to what could be different between the two?
Wondering if anyone can shed some light on why I can't get this API call to work. Just trying to get form entry data. If I paste the URL to the JSON into my browser, it displays as you'd expect but in this call I can't get any server response.
<?php
$api_uri_1 = "https://eastbankads.wufoo.com/api/v3/forms/z1qh9i4b1qg5qa6/entries.json";
function wufoo_api($api_uri) {
$curl = curl_init($api_uri);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, 'MY-API-KEY:password');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Wufoo Sample Code');
$response = curl_exec($curl);
$resultStatus = curl_getinfo($curl);
if ($resultStatus['http_code'] == 200) {
$results = json_decode($response, true);
return $results;
} else {
$results = 'Call Failed '.print_r($resultStatus);
return $results;
}
}
$result1 = wufoo_api($api_uri_1);
?>
I've checked & doubled checked my API key. Here's a link to my test page and the output that's given from the code:
http://resources.worldoftile.net/wufoo-perfect-project-entries/
Or, this is what is output on that page:
Array (
[url] => https://eastbankads.wufoo.com/api/v3/forms/z1qh9i4b1qg5qa6/entries.json
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 132
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.068676
[namelookup_time] => 2.2E-5
[connect_time] => 0.009197
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0.068764
[certinfo] => Array ( )
[primary_ip] => 75.98.93.66
[redirect_url] =>
)
Removing the below line will fix this issue.
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.