public static function generateFromResponse($response, $adapter) { $profile = parent::generateFromResponse($response, $adapter); $uid = static::parser('uid', $response); $profileUrl = $uid ? 'http://ok.ru/profile/' . $uid : ''; $bDate = static::parser('birthday', $response); $firstName = static::parser('first_name', $response); $lastName = static::parser('last_name', $response); $location = static::parser('location', $response); $profile->setIdentifier($uid); $profile->setFirstName($firstName); $profile->setLastName($lastName); $profile->setDisplayName($firstName . ' ' . $lastName); $profile->setProfileURL($profileUrl); $profile->setPhotoURL(static::parser('pic1024x768', $response)); if (isset($location->city)) { $profile->setCity($location->city); } if (isset($bDate)) { $buf = explode('-', $bDate); if (isset($buf[2])) { $profile->setBirthDay(sprintf("%'.02d", $buf[2])); } if (isset($buf[1])) { $profile->setBirthMonth(sprintf("%'.02d", $buf[1])); } if (isset($buf[0])) { $profile->setBirthYear($buf[0]); } } $sex = static::parser('gender', $response); $profile->setGender($sex); return $profile; }
public static function generateFromResponse($response, $adapter) { $profile = parent::generateFromResponse($response, $adapter); $screenName = static::parser('screen_name', $response); $bDate = static::parser('bdate', $response); $firstName = static::parser('first_name', $response); $lastName = static::parser('last_name', $response); $profile->setIdentifier(static::parser('uid', $response)); $profile->setFirstName($firstName); $profile->setLastName($lastName); $profile->setDisplayName($firstName . ' ' . $lastName); $profileUrl = $screenName ? 'http://vk.com/' . $screenName : 'http://vk.com/id' . $profile->getIdentifier(); $profile->setProfileURL($profileUrl); $profile->setPhotoURL(static::parser('photo_max_orig', $response)); if (isset($bDate)) { $buf = explode('.', $bDate); if (isset($buf[0])) { $profile->setBirthDay(sprintf("%'.02d", $buf[0])); } if (isset($buf[1])) { $profile->setBirthMonth(sprintf("%'.02d", $buf[1])); } if (isset($buf[2])) { $profile->setBirthYear($buf[2]); } } $sex = static::parser('sex', $response); if ($sex) { switch ($sex) { case 1: $sex = 'female'; break; case 2: $sex = 'male'; break; default: $sex = null; } } $profile->setGender($sex); return $profile; }