Exemple #1
0
 public function testReadEmpty()
 {
     $reader = new Form();
     $message = new Message(array(), '');
     $form = $reader->read($message);
     $this->assertNull($form);
 }
Exemple #2
0
 /**
  * Exchange an request token with an access token. We receive the "token"
  * and "verifier" from the service provider wich redirects the user to the
  * callback in this redirect are the $token and $verifier. Returns an access
  * token and secret i.e.
  * <code>
  * $response = $oauth->accessToken(...);
  *
  * $token       = $response->getToken();
  * $tokenSecret = $response->getTokenSecret();
  * </code>
  *
  * @see http://tools.ietf.org/html/rfc5849#section-2.3
  * @param \PSX\Url $url
  * @param string $consumerKey
  * @param string $consumerSecret
  * @param string $token
  * @param string $tokenSecret
  * @param string $verifier
  * @param string $method
  * @return \PSX\Oauth\Provider\Data\Response
  */
 public function accessToken(Url $url, $consumerKey, $consumerSecret, $token, $tokenSecret, $verifier, $method = 'HMAC-SHA1')
 {
     $values = array('oauth_consumer_key' => $consumerKey, 'oauth_token' => $token, 'oauth_signature_method' => $method, 'oauth_timestamp' => self::getTimestamp(), 'oauth_nonce' => self::getNonce(), 'oauth_version' => self::getVersion(), 'oauth_verifier' => $verifier);
     // build the base string
     $requestMethod = 'POST';
     $params = array_merge($values, $url->getParameters());
     $baseString = self::buildBasestring($requestMethod, $url, $params);
     // get the signature object
     $signature = self::getSignature($method);
     // generate the signature
     $values['oauth_signature'] = $signature->build($baseString, $consumerSecret, $tokenSecret);
     // request access token
     $request = new PostRequest($url, array('Authorization' => 'OAuth realm="psx", ' . self::buildAuthString($values), 'User-Agent' => __CLASS__ . ' ' . Base::VERSION));
     $response = $this->http->request($request);
     // parse the response
     $reader = new Form();
     $record = new Response();
     $importer = new ResponseImporter();
     $importer->import($record, $reader->read($response));
     return $record;
 }