function oauthAccessToken() { $code = $_REQUEST["code"]; $verifier = $this->api["verifier"]; //something tricky here... Facebook hates urlencode and drops the '=' on the verifier when it matches the redirect_uri $params = array("code" => $code, "client_secret" => $this->api["secret"], "redirect_uri" => $verifier . "?oauth_verifier", "client_id" => $this->api["consumer_key"]); $r = DTHTTPRequest::makeHTTPRequest("https://graph.facebook.com/oauth/access_token", $params); parse_str($r->getResponseBody(), $response); $this->setAccessToken($response["access_token"], ""); // it's no secret that OAuth 2.0 is no fun }
public function request($action, array $params = array(), $method = 'GET') { $params["key"] = $this->api["consumer_key"]; //DTLog::debug($action); $r = DTHTTPRequest::makeHTTPRequest($this->url . $action, $params, $method, $_SESSION["{$this->api["name"]}_cookies"], array("Zotero-API-Version", 3)); if ($r) { if (($backoff = $r->getResponseHeader("Backoff")) > 0) { DTLog::warn("Zotero has requested a backoff period ({$backoff} seconds)."); sleep($backoff); } //DTLog::debug($r->getResponseBody()); return $r->getResponseCode() == 200 ? $r->getResponseBody() : false; } return null; }