I’m calling the Google Places Photo API like so in my Laravel PHP app:
public static function getpic ($photoreference){
$app_id = 'XXXYYYZZZ';
$URLToCall = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=225&photoreference=$photoreference&sensor=false&key=$app_id";
$result = file_get_contents($URLToCall);
return $result;
}
When I print_r $result, I get:
string(12902) "ÿØÿàJFIFÿá`ExifII*1&i‡.Picasa0220 á –ÿÛ„
I can’t figure out how to use what’s returned. I attempted to pass the string to a view, but that failed.
Any suggestion?
According to the docs, the response is an image. That would explain why printing it would result in binary data, like you’re seeing.
Basically, you’ll want to save this data, and then embed the image like you would in regular HTML, or just set the img src to point to the $URLToCall