0

Tengo este código en lumen (laravel) que me devuelve por una parte los usuarios de mi dominio Gsuite(funciona correctamente) , tengo todos los datos de los usuarios en un archivo Json en el objeto $users , allí recibo un JSON como este

{  
"data":{  
  "etag":"\"LW8ywR8igXXXX6tx8gAGB-fySsA\/Xg8OYbk99s-_SE6WTGelfAGC_Jg\"",
  "kind":"admin#directory#users",
  "nextPageToken":null,
  "triggerEvent":null,
  "users":[  
     {  
        "addresses":null,
        "agreedToTerms":true,
        "aliases":null,
        "changePasswordAtNextLogin":false,
        "creationTime":"2016-11-07T16:25:12.000Z",
        "customSchemas":{  
           "Legal":{  
              "DNI":"XXXXXXX"
           }
        },
        "customerId":"XXXXX",
        "deletionTime":null,
        "emails":[  
           {  
              "address":"[email protected]",
              "primary":true
           }
        ],
        "etag":"\"LW8ywR8igJCaw6tx8gAGB-fySsA\/9R6JNs03hf_Rqjf3RiXXXXZI7fI\"",
        "externalIds":[  
           {  
              "value":"",
              "type":"organization"
           }
        ],
        "gender":null,
        "hashFunction":null,
        "id":"117875884468373414859",
        "ims":null,
        "includeInGlobalAddressList":true,
        "ipWhitelisted":false,
        "isAdmin":false,
        "isDelegatedAdmin":false,
        "isEnforcedIn2Sv":false,
        "isEnrolledIn2Sv":false,
        "isMailboxSetup":true,
        "keywords":null,
        "kind":"admin#directory#user",
        "languages":null,
        "lastLoginTime":"2018-05-17T13:26:12.000Z",
        "locations":null,
        "nonEditableAliases":[  
           "[email protected]"
        ],
        "notes":null,
        "orgUnitPath":"\/Test\/Staff",
        "organizations":[  
           {  
              "title":"",
              "primary":true,
              "customType":"",
              "department":"",
              "description":"",
              "costCenter":""
           }
        ],
        "password":null,
        "phones":null,
        "posixAccounts":null,
        "primaryEmail":"[email protected]",
        "relations":null,
        "sshPublicKeys":null,
        "suspended":false,
        "suspensionReason":null,
        "thumbnailPhotoEtag":"\"LW8ywR8igJCaw6tx8gAGB-fySsA\/6b9SRWNtq1X9GrCKuBx0oIH5cUw\"",
        "thumbnailPhotoUrl":"https:\/\/plus.google.com\/_\/focus\/photos\/private\/AIbEiAIAAABECMvHx7rqxvmJ-AEiC3ZjYXJkX3Bob3RvKihmOWRXXXXMDA0N2FhNGFjOTg5MWMyMGQ3ZmUwYTZkOTI2NjlmZjcwMAH-M7eUA1IQrHaJjVkj/JFgn4eqHw",
        "websites":null,
        "name":{  
           "familyName":"AAA",
           "fullName":"AAA BBB",
           "givenName":"CCCC"
        }
     },

}

En el Json hay una propiedad que es users.thumbnailPhotoUrl que me devuelve una URL que si la pongo en el navegador me sale un "icono azul" cuando este usuario si que tiene foto de perfil...por lo que no tengo claro si este campo es el que debo buscar para recojer la foto del perfil y mostrarla.

La función que uso es esta

    public function getUsersDirectory (Request $request)
{

    putenv('GOOGLE_APPLICATION_CREDENTIALS='.resource_path('credentials/admin/credentials.json'));

    $client = new \Google_Client();
    $client->useApplicationDefaultCredentials();
    $client->setSubject('[email protected]');

    $scopes = implode(' ', [
        \Google_Service_Directory::ADMIN_DIRECTORY_USER_READONLY
    ]);

    $client->setScopes($scopes);

    $service = new \Google_Service_Directory($client);
    $users = $service->users->listUsers(array('domain' => ['mydomain.com'], 'maxResults' => 500, 'projection' => 'full'));



    $client2 = new \Google_Client();
    $client2->useApplicationDefaultCredentials();
    $client2->setSubject('[email protected]');

    $scopes2 = implode(' ', [
        \Google_Service_Directory::ADMIN_DIRECTORY_USER_READONLY
    ]);

    $client2->setScopes($scopes2);

    $adminService = new \Google_Service_Directory($client);
    $users = $adminService->users_photos->get('[email protected]');

    return $this->jsonOKResponse($users);

}

Como se observa en esta función $users devuelve realmente el listado de usuarios y luego hago una llamada a la api que me devuelve este otro JSON pero no se como mostrar el contenido de "photoData"

{  
"data":{  
  "etag":"\"LW8ywR8igJCawXXXXXGB-fySsA\/7IZpDcxsaPUSKAQ9UkLcyJ9x_sQ\"",
  "height":96,
  "id":"108927737425187213905",
  "kind":"admin#directory#user#photo",
  "mimeType":"image\/jpeg",
  "photoData":"_9j_4AAQSkZJRgABAQAAAQABAAD_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TZCVvuouzFVyWYMttofvDkv5R6OGNcN_8AFWH-1a0IVVvZt-gfLJKSbBuOyTokm6IGKiS8Smaolm0i9vVA3TbllncTa1aDzKWcuEm2lIjeFFoV7nc8KJGV4bLCQutXEQoXvzTa90EJBpvVkA_Zum2N3Tmgl_OA-KUP-a2tHRZ8SyAT_EBCP5pF_R_GJmTcJwCAiUbSboShSqLnn05fOKyBESbgnroUNP8AqBiHdl_4C_vg5oryg3uCMy0DbalaTwKVG17VBa5RnL7Po6xHCBcHL2yIvK0v_VIH4kEqYzgkB9P5_VSxNjvOAN3bZVbv0r8Fgw64ICREVoilxF4IlS-UZzpHiDk0RObQiqWgPdEVLVV8c1-KwrFO2FlrS0Egb2R-6MesNiRF4R9IHc0C-wPyieGFtGn3ostikiXNovSOFuOkKA2REvhnDvyV6PyU49O87Im22ZKYmw2xbQjbNhBQlVN2017OqNPlJ3AMFHSGWGdYIZmcukCkSemi5pWfBuXKYZfBCWw5daKRD0VQlSkEpFVk1wjK9GuSrFjxGXlXWClnJ5l2ZYF0m2VIWW1cOusXYqCIqVRK1SGLC-S0QxaTkJt7mnPpU5sCNtxzVOAc2wTb4Kiaqhyi1XoRKrDWeOYpjD2EzcoxLtsNTP7F1gjc42U5JyspNK7YKa1pRE1RVzRXKVXKDfKBovN8_wBGlxOfdxEXXQwsisbbUW0MVaBHAVVMrnDzVa5w-fT01v6Kd-uia9rfPPCMT01wA5WZWWdY1DrKm08FopaQqiLu73-UgZJ4JMu-pln39n7Ntxz9ArH7LwbQnCWLSCQl7kG7WOt61wVWl1Deqtap-UMZSIi3S5O7aKUSiqqRY_DnzRmv_ayJfpj4XlvR-CTlfRkn12RWkZe0i8RL-sNOLygg4633TNv3itP5QKVu1sj7BMi6skTajNfD0emjmUz_2Q==",
  "primaryEmail":"[email protected]",
  "width":96
   }
}

1 respuesta 1

0

Por lo que veo, la imagen ya te es devuelta, entonces lo único que tienes que hacer es establecer los datos dentro de una etiqueta de img de la siguiente manera:

<img src="data:image/j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X441MzZE05c2lrbXknWgdlax20Xxx2TKrTYODdcTZCVvuouzFVyWYMttofvDkv5R6OGNcN_8AFWH-1a0IVVvZt-gfLJKSbBuOyTokm6IGKiS8Smaolm0i9vVA3TbllncTa1aDzKWcuEm2lIjeFFoV7nc8KJGV4bLCQutXEQoXvzTa90EJBpvVkA_Zum2N3Tmgl_OA-KUP-a2tHRZ8SyAT_EBCP5pF_R_GJmTcJwCAiUbSboShSqLnn05fOKyBESbgnroUNP8AqBiHdl_4C_vg5oryg3uCMy0DbalaTwKVG17VBa5RnL7Po6xHCBcHL2yIvK0v_VIH4kEqYzgkB9P5_VSxNjvOAN3bZVbv0r8Fgw64ICREVoilxF4IlS-UZzpHiDk0RObQiqWgPdEVLVV8c1-KwrFO2FlrS0Egb2R-6MesNiRF4R9IHc0C-wPyieGFtGn3ostikiXNovSOFuOkKA2REvhnDvyV6PyU49O87Im22ZKYmw2xbQjbNhBQlVN2017OqNPlJ3AMFHSGWGdYIZmcukCkSemi5pWfBuXKYZfBCWw5daKRD0VQlSkEpFVk1wjK9GuSrFjxGXlXWClnJ5l2ZYF0m2VIWW1cOusXYqCIqVRK1SGLC-S0QxaTkJt7mnPpU5sCNtxzVOAc2wTb4Kiaqhyi1XoRKrDWeOYpjD2EzcoxLtsNTP7F1gjc42U5JyspNK7YKa1pRE1RVzRXKVXKDfKBovN8_wBGlxOfdxEXXQwsisbbUW0MVaBHAVVMrnDzVa5w-fT01v6Kd-uia9rfPPCMT01wA5WZWWdY1DrKm08FopaQqiLu73-UgZJ4JMu-pln39n7Ntxz9ArH7LwbQnCWLSCQl7kG7WOt61wVWl1Deqtap-UMZSIi3S5O7aKUSiqqRY_DnzRmv_ayJfpj4XlvR-CTlfRkn12RWkZe0i8RL-sNOLygg4633TNv3itP5QKVu1sj7BMi6skTajNfD0emjmUz_2Q==">

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.