CURL Request Issue

sehelly218

New Member
So I'm a beginner to all of this. I'm attempting to teach myself how to properly use CURL, and dabble a bit in API calls (don't worry, this question only relates to using CURL).Now my original code worked just fine - I structured the request using urlencode, and the vast majority of requests leaded to the responses I was looking for. About 10% of the received responses, however, that wouldn't retrieve the results I needed. Let me give an example:\[code\]$urlToFetch = "http://lsapi.seomoz.com/linkscape/url-metrics/" . urlencode($objectURL) . "?" . $this->structureURL();$response = ConnectionUtil::makeRequest($urlToFetch);\[/code\]Using the above code would generate a $urlToFetch with the following data:http://lsapi.seomoz.com/linkscape/u...XXXXXX&Expires=1286388878&Signature=YYYYYYYYYThis passes through CURL, and gets a response from the seoMoz API - the response, however, is missing some data. I've poked around, and found that it is an issue with how the URL is structured. For example, by changed the value from \[code\]www.alinki.com%2Fdomainlinks.php%3Fpage%3D516000\[/code\] to \[code\]www.alinki.com/domainlinks.php?page=516000\[/code\] I can retrieve all the fields I am looking for. Going by that logic, I should be able to structure a URL similar to this:(I'm removing the http since I cannot post more than one link) \[code\]lsapi.seomoz.com/linkscape/url-metrics/www.alinki.com/domainlinks.php?page=516000?AccessID=XXXXXX&Expires=1286388878&Signature=YYYYYYYYY\[/code\]and retrieve all the fields I need. The problem is, when I attempt to pass that URL through to CURL, it will not complete the request. Below is the code used for the CURL request:\[code\]public static function makeRequest($urlToFetch){$curl_handle = curl_init();curl_setopt($curl_handle, CURLOPT_URL, "$urlToFetch");curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, ConnectionUtil::CURL_CONNECTION_TIMEOUT);curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);$buffer = curl_exec($curl_handle);//var_dump($buffer);curl_close($curl_handle);$arr = json_decode($buffer);return $arr;}\[/code\]And I request as follows:\[code\] $urlToFetch = "http://lsapi.seomoz.com/linkscape/url-metrics/" . urlencode($objectURL) . "?" . $this->structureURL(); $response = ConnectionUtil::makeRequest($urlToFetch);\[/code\]Any ideas on what silly mistake I am making?
 
Back
Top