예제 #1
0
 /**
  * Need to override this method for flattr, since they use oauth2
  */
 protected function send($pPostBody)
 {
     $lToken = $this->getAuthToken();
     if ($pPostBody) {
         return UrlUtils::sendPostRequest(sfConfig::get("app_" . $this->classToIdentifier() . "_post_api"), $pPostBody, array("Authorization: Bearer " . $lToken->getTokenKey(), "Content-type: application/json"));
     }
     return null;
 }
예제 #2
0
 /**
  * Need to override this method for facebook, since they use oauth2
  *
  */
 protected function send($pPostBody)
 {
     $this->onlineIdentity->scheduleImportJob();
     Queue\Queue::getInstance()->put(new Documents\InterestImportJob($this->onlineIdentity->getId()));
     $lToken = $this->getAuthToken();
     $pPostBody .= "&access_token=" . $lToken->getTokenKey();
     return UrlUtils::sendPostRequest(sfConfig::get("app_" . $this->classToIdentifier() . "_post_api"), $pPostBody);
 }
예제 #3
0
 /**
  * retrieve the access token
  *
  * @author Matthias Pfefferle
  * @param string $pCode
  */
 public function getAccessToken($pCode)
 {
     $lConsumer = $this->getConsumer();
     $lHeaders = array('Authorization: Basic ' . base64_encode($lConsumer->key . ':' . $lConsumer->secret), "Content-Type: application/json");
     $lBody = json_encode(array("code" => $pCode, "grant_type" => "authorization_code", "redirect_uri" => $this->getCallbackUri()));
     $lAccessUrl = "https://flattr.com/oauth/token";
     $lAccessToken = UrlUtils::sendPostRequest($lAccessUrl, $lBody, $lHeaders);
     return $lAccessToken;
 }
예제 #4
0
 public function testInvalidRequest()
 {
     $user = Doctrine_Core::getTable('sfGuardUser')->createQuery('u')->where('u.is_active = ?', true)->fetchOne();
     $data = UrlUtils::sendPostRequest("http://api.spreadly.local/deals?access_token=" . $user->getAccessToken(), self::$INVALID_TEST_JSON);
     $data = json_decode($data, true);
     $this->assertEquals("406", $data['error']['code']);
 }
예제 #5
0
 /**
  * do a post
  *
  * @param string $url
  * @param string $data
  * @param array $header http header
  * @return string post-body
  */
 private static function doPost($url, $data, $header = null)
 {
     return UrlUtils::sendPostRequest($url, $data, $header);
 }