phpcurlyahoo-maps

yahoo maps api curl settings


How should I configure cURL to retrieve data from the yahoo maps api?

Here is the current code

curl_setopt($ch, CURLOPT_TIMEOUT, 5000);
curl_setopt($ch, CURLOPT_URL, $geocodeurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);

Which returns a 400 - Bad request HTML file. I've checked $geocodeurl and it is a valid XML file, so I figure the problem must be the cURL options?


$geocodeurl is

 http://where.yahooapis.com/geocode?appid=** My App ID **&q=Battle%20Creek,MI&gflags=R

Solution

  • OK as usual I had misidentified the problem. cURL was fine, but the q= variable was not being passed through any sort of urlencode function correctly.

    Worked in my browser because Firefox kindly changed the to %20. With cURL you need to be more careful. . . .