/** * Extend a current access token for up to 60 days * * Return data has two keys * - access_token Is the new access token * - expires Is how long the new access token will be valid for (up to 60 days) * * Can throw Curl and Facebook exceptions * * @param string $access_token An old access token that belongs to this application * @return array */ public static function extendAccessToken($access_token) { $curl = new \Nodes\Curl(); $params = http_build_query(array('client_id' => Configure::read('Facebook.appId'), 'client_secret' => Configure::read('Facebook.secret'), 'grant_type' => 'fb_exchange_token', 'fb_exchange_token' => $access_token)); $response = $curl->setOption(CURLOPT_URL, sprintf('https://graph.facebook.com/oauth/access_token?%s', $params))->get()->getResponseBody(); parse_str($response, $res); return $res; }
protected function _delete($params) { if (static::$_embedded) { return false; } $request = new \Nodes\Curl(); $request->setOption(CURLOPT_URL, $url = $this->_buildRequestURI($params)); $request->delete(); $responseBody = $request->getResponseBody(); if (isset($responseBody['error'])) { throw new Exception($responseBody['error']['message'], $responseBody['error']['code']); } return $request; }