/**
  * @param \SimpleXMLElement $xmlElement
  * @return Consumer
  */
 public static function parseFromXml(\SimpleXMLElement $xmlElement)
 {
     $consumer = new self();
     if (!empty($xmlElement->key)) {
         $consumer->setKey((string) $xmlElement->key);
     }
     if (!empty($xmlElement->secret)) {
         $consumer->setSecret((string) $xmlElement->secret);
     }
     if (!empty($xmlElement->name)) {
         $consumer->setName((string) $xmlElement->name);
     }
     return $consumer;
 }
Example #2
0
 /**
  * Method for object initialization by the string
  * @param string $string redirect string with access token data
  * @return Token response object
  */
 public static function initializeByString($string)
 {
     $data = array();
     parse_str($string, $data);
     $Response = new self();
     $Response->setAccessToken($data['access_token'])->setExpiresIn($data['expires_in']);
     if (isset($data['user_id'])) {
         $Response->setUserId($data['user_id']);
     }
     if (isset($data['secret'])) {
         $Response->setSecret($data['secret']);
     }
     return $Response;
 }