I have little function for get content result with cURL; When i tried without POST, all working good, but with POST enabled, the result is null.
This code don't work:
function getAPI($url){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS,'shard=Apex');
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3");
$result = curl_exec($ch);
return $result;
curl_close($ch);
}
This code work but the request is not passed like a POST:
function getAPI($url){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
//curl_setopt($ch,CURLOPT_POST, true);
//curl_setopt($ch,CURLOPT_POSTFIELDS,'shard=Apex');
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3");
$result = curl_exec($ch);
return $result;
curl_close($ch);
}
I call this function with this command:
echo getAPI('http://world.needforspeed.com/SpeedAPI/ws/cmsbridge/news/rss/fr_FR');
You can also try with this URL
http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/levelkro/profile
This URL work only if shard=Apex (default shard=CHICANE for CHHICANE Server, but my profil is only available on Apex Server)
<?xml version="1.0" encoding="UTF-8"?> <null/>. So is this API meant to be posted to?arrayfor youCURL_POSTFIELDS?