0

I'm trying to use the Directory API to pull user information, which I'm able to do, but I can't seem to find any good examples on how to access user images.

I tried the following, which gets me a photo resource:

$photo = $service->users_photos->get($uid);

After that I found the utility method for web-safe base64 decoding and tried to access the data like so:

$data = Google_Utils::urlSafeB64Decode($data);
$data = base64_encode($data);
return "data:" . $mime . ";base64," . $data;

However, this produces a pixelated image. So I'm either missing a step or something is wrong with the data I'm getting. I can't seem to find any documentation on how to get this image using PHP, is there an official method for decoding the bytes received in photoData and converting them to an image?

  • Can you include the response json from the query? Perhaps its the resolution of the image which is really small by default. Have you tested with more than 1 user? – Rivero Aug 27 '15 at 23:17
  • It looks like something was wrong with the image that was uploaded to Gmail. I uploaded a new image and the above code worked perfectly. – Drezden Aug 29 '15 at 15:23

0 Answers0