/** * Verify OAuth Twitter credentials. * @return mixed null if not authorized; array of user data if authorized * @throws Exception if HTTP status code from Twitter is not 200 OK */ public function verifyCredentials() { $endpoint = $this->endpoints['credentials']->getPath(); $args = array('include_entities' => 'false', 'skip_status' => 'true'); $payload = $this->to->OAuthRequest($endpoint, 'GET', $args); $http_status = $this->to->lastStatusCode(); if ($http_status == 200) { $user = $this->parseJSONUser($payload); return $user; } else { throw new APIErrorException(self::translateErrorCode($http_status, true)); } }
/** * Make an API request from the webapp (as opposed to the crawler) * @param str $url * @return array (cURL status, cURL retrieved content) */ public function apiRequestFromWebapp($url) { $content = $this->to->OAuthRequest($url, 'GET', array()); $status = $this->to->lastStatusCode(); return array($status, $content); }