2nd Curl Request talking 30 seconds
I am trying to make to curl requests to a website's API. It works fine but
the second request takes 30 seconds to complete, but it does not do this
when I try it on the postman chrome extension? So the problem must be with
the curl script.
Heres the code:
<?php
function getfeed($url){
$ip = $_SERVER['REMOTE_ADDR'];
$ch = curl_init();
curl_setopt($ch,CURLOPT_USERAGENT,'Opera/9.80 (Macintosh; Intel Mac OS
X; U; en) Presto/2.2.15 Version/10.00');
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"client_ip=$ip&type=1&app_id=foo&app_secret=bar");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_AUTOREFERER,1);
curl_setopt($ch,CURLOPT_FRESH_CONNECT,1);
$response = curl_exec ($ch);
curl_close ($ch);
return $response;
}
echo $filmon_session =
json_decode(getfeed("http://www.filmon.com/api/init"))->session_key;
$channels =
json_decode(getfeed("http://www.filmon.com/api/channels?session_key=$filmon_session"));
print_r($channels);
?>
No comments:
Post a Comment