示例#1
0
 /**
  * Parse a successful paste listing response.
  * @param string $response The response to parse.
  * @param \Brush\Accounts\Account $owner The optional owner of these pastes.
  * @return \Brush\Pastes\Paste[] The parsed pastes.
  */
 public static function parsePastes($response, Account $owner = null)
 {
     if ($response == 'No pastes found.') {
         return array();
     }
     $pastes = array();
     foreach (ApiRequest::toElement('<pastes>' . $response . '</pastes>')->getElementsByTagName('paste') as $paste) {
         $pastes[] = Paste::fromXml($paste, $owner);
     }
     return $pastes;
 }
示例#2
0
文件: User.php 项目: gebn/brush
 /**
  * Retrieve a user's information from their account.
  * @param \Brush\Accounts\Account $account The account whose corresponding information to retrieve.
  * @param \Brush\Accounts\Developer $developer The developer account to use for the request.
  * @return \Brush\Accounts\User A user instance containing the account's information.
  */
 public static final function fromAccount(Account $account, Developer $developer)
 {
     $key = $account->getCacheKey($developer);
     if (self::getCache()->isCached($key)) {
         // user cache hit
         return self::getCache()->get($key);
     }
     $pastebin = new ApiRequest($developer, self::ENDPOINT);
     $pastebin->setOption('userdetails');
     $account->sign($pastebin->getRequest(), $developer);
     $user = self::fromXml(ApiRequest::toElement($pastebin->send()));
     self::getCache()->set($key, $user);
     return $user;
 }