api - CURL can't connect? Just hangs and doesn't respond. PHP has it enabled -
api - CURL can't connect? Just hangs and doesn't respond. PHP has it enabled -
i have simple php function on friend server i've checked , has php curl enabled.
the function is:
function sw_fetch_code($apikey='',$email=''){ $url = "http://www.domain.com/xxx/api.php?getcode=1&apikey=".$apikey."&email=".$email.""; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_header, 1); $result = curl_exec($ch); curl_close($ch); $obj = json_decode($result); if(!empty($obj)){ if($obj->status == 200){ homecoming $obj->code; }else{ homecoming $obj->status; } } }
as can see simple , i've tested , works on localhost , internal own server. url returns expected. doesn't give response when function called on friends server.
any ideas cause this?
first : check "friend" server if url works, donot have post params, can check exact query , expected results. see if can results on browser on friend server. if don't have gui seek wget on command line. see if results. if go next step, if don't curl isn't problem. "friend server" isn't able see domain. network issue / hosts etc .. (more on if case)
second: if see results on step 1. seek , see if anything:
$handle = fopen($url, "rb"); $contents = ''; while (!feof($handle)) { $contents .= fread($handle,1024); }
if response this, there wrong curl.
php api curl
Comments
Post a Comment