Currently, I'm trying to pass an image in the response, however, I keep getting "Malformed UTF-8 characters, possibly incorrectly encoded" error. When I check the value of $image, I get something like this:
└äÐ`>░Ç╚I#FGkT§5tëSNiÍ-rÜ╩Uþ4¯_B¼Ê\x05 \x00î·éj\x1C÷▓Ñ▄\e╦\v\x01┌(Í\x0Fb~"òæIµ
└¤u\x7FÕ}ºD§ÁtÅ\x08\x12²W*y|Ñój╔ýâ¿:@ì#êü©\x12‗ıTÂÿÐC·YfÐ \x00\x02T┴-Aê═╚êòS#▒/
\x18U@J¦L═\x1F0│Gx§n\x0E£W\x1CW¶┤ñå«YÜ\x07é\x00iär[╩\\x02Z)\x127P\x1Cy@\rc▀Åb\x
07xÚ\vÇ{Zâ9╦bö\x00ÆF‗F╔ IyR$m╩,ÑJ╝rº,ò*C+\x15╣(°êevÊÒ═£ıcÝkË{2/\x18╔\x1FZÃıR\x7F
Goú,ÈÔ×óÂ║òi¦ÆXÞfrÞ‗28þ┤N\x1EØøò¿ñ▒$£ð\fh└\x03"╬i(Ô¬I*ÒºY`ûIÒ¯5M3┼\tûÉñ┤
I've read that all I have to do to display an image, is put what is inside $image into the src of an image tag on the front end, however, I can't pass it since I'm getting the aformentioned error
public function getSight(Request $request, $placeid) {
$get = file_get_contents("https://maps.googleapis.com/maps/api/place/details/json?placeid=" . $placeid . "&key=");
$result = json_decode($get);
$image = file_get_contents("https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU&key=");
return response()->json([
'message' => 'Fetched sight!',
'result' => $result,
'image' => $image
], 201);
}
file_get_contents
on the actual image? Are you sure you just don't want to return a url to the image in your response? - Mozammil