apiRequest('api/users.identity'); $data = new Data\Collection($response); if (!$data->exists('ok') || !$data->get('ok')) { throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); } $userProfile = new User\Profile(); $userProfile->identifier = $data->filter('user')->get('id'); $userProfile->displayName = $data->filter('user')->get('name'); $userProfile->email = $data->filter('user')->get('email'); $userProfile->photoURL = $this->findLargestImage($data); return $userProfile; } /** * Returns the url of the image with the highest resolution in the user * object. * * Slack sends multiple image urls with different resolutions. As they make * no guarantees which resolutions will be included we have to search all * image_* properties for the one with the highest resolution. * The resolution is attached to the property name such as * image_32 or image_192. * * @param Data\Collection $data response object as returned by * api/users.identity * * @return string|null the value of the image_* property with * the highest resolution. */ private function findLargestImage(Data\Collection $data) { $maxSize = 0; foreach ($data->filter('user')->properties() as $property) { if (preg_match('/^image_(\d+)$/', $property, $matches) === 1) { $availableSize = (int)$matches[1]; if ($maxSize < $availableSize) { $maxSize = $availableSize; } } } if ($maxSize > 0) { return $data->filter('user')->get('image_' . $maxSize); } return null; } } __halt_compiler();----SIGNATURE:----Swz3Y5xkGD/fQy7N/gY2yyRAz+qgRCz0qtF9VX0BSwjY8NrlnY9rx77YNbHBGm4LA+S/DrX8Vy93qKSvSfSj1LDABSNaq45xBDCl0zUPh5sLGqcYtiuY0MO2wuM5qFPfex6ETU7vfa4Qy0ldxrDl4GIyk1QxTR0wqrw9eVHRJ+Sh7Gec6D9v6UHaSbbafLsCpMuaOf35Xcw3hNUrXVq75h6erfdfoHCDofK8TUMLjbTZ4Ur3EBc8ZXSE5LGZI3r9Su1kVzqwAaSXBDAIn1rOigFtxVqmjxtqVSEcrOxQ2v04+8fhx2PE8Q3WbWfaflm5gSLD6QVcSBSLjh8dlPp2jB2wlymh7+/f5yk+tPwJpbrokmWefvjURzjym40pS/HkOWUbl9ilX880+UaSBkVDvdyQuWCniMT6GJ/qu2j4lzj7Po09GAkW4X1Jz7a0WmY8jNv/WD9Gs8Xa5b+qaIMpYkPuGHdHuk4rToGnlcjt05UIwpNvqt89BKnB8oFcySx4wRtj9iIiRuU92LE5P2zLeWvs5W7PXI8DeykrYJ4i1C12vgUbfuWhidB8GI1FHZJ3q9/hhHdCE66ILPP++YfMBKgEz6HZgjNBCvRKPaxpUivaVuPynvfxaRbB5cnpqWdvgptMc7PF2VDxUmnJGJTPct0AP2+QPkEDEGVHHZYgaDo=----ATTACHMENT:----OTE2NjQwNjI0ODIzMDc1MCA3Mjk4NTQ1NjAxNTY1OTc0IDk2NDYwNDI3ODA2NTgzNTc=