private function getApiUrl($path, $getParameters = []) { $link = new Link(self::TWITTER_API_URL . '/' . self::TWITTER_API_VERSION . '/' . $path . '.json'); if ($getParameters) { foreach ($getParameters as $key => $value) { $link->addQueryParameter($key, $value); } } return $link; }
private function exchangeCodeForAccessToken() { $link = new Link(Graph::getGraphUrl('oauth/access_token')); $link->addQueryParameter('client_id', $this->config->getAppID()); $link->addQueryParameter('client_secret', $this->config->getAppSecret()); $link->addQueryParameter('code', $this->getCode()); $link->addQueryParameter('redirect_uri', $this->getRedirectUrl()); $request = new RequestMaker(Method::METHOD_GET, $link); $request->setSecurityCertificate(__DIR__ . '/Certificates/DigiCertHighAssuranceEVRootCA.pem'); $transporter = $this->getTransporter($request); $transporter->send(); $this->response = $transporter->getResponse(); $this->responseData = json_decode($this->response->getBody()); }
public function testIsSecure() { $link = new Link($this->link); $this->assertTrue($link->isSecureLink()); }
public function testEmptyQueryString() { $link = new Link('http://localhost/md.php'); $this->assertEquals('', $link->getQueryString()); }
/** * The scheme, authority, and path of the request resource URI [RFC3986] * are included by constructing an "http" or "https" URI representing * the request resource (without the query or fragment) as follows: * For example, the HTTP request: * GET /r%20v/X?id=123 HTTP/One.One * Host: EXAMPLE.COM:80 * is represented by the base string URI: "http://example.com/r%20v/X" * In another example, the HTTPS request: * GET /?q=One HTTP/One.One * Host: www.example.net:8080 * is represented by the base string URI: * "https://www.example.net:8080/". * @param Link $link * @return null|string */ private function getBaseStringURI(Link $link) { //The scheme and host MUST be in lowercase. //The host and port values MUST match the content of the HTTP //request "Host" header field $url = $link->getScheme() ? strtolower($link->getScheme() . '://') : null; $url .= $this->encode(strtolower($link->getHost())); //The port MUST be included if it is not the default port for the //scheme, and MUST be excluded if it is the default. Specifically, //the port MUST be excluded when making an HTTP request [RFC2616] //to port 80 or when making an HTTPS request [RFC2818] to port 443. //All other non-default port numbers MUST be included. $url .= $link->getPort() && ($link->getPort() != 80 || $link->getPort() != 443) ? ':' . $link->getPort() : null; $url .= $link->getPath() ? $link->getPath() : '/'; return $url; }
public function requestAuthorization() { $link = new Link($this->resourceOwnerAuthorizationUrl); $link->addQueryParameter('oauth_token', $this->temporalTokenKey); header('Location: ' . $link); }
public function requestAuthorization() { $link = new Link('https://api.twitter.com/oauth/authorize'); $link->addQueryParameter('oauth_token', isset($this->responseData['oauth_token']) ? $this->responseData['oauth_token'] : null); header('Location: ' . $link); }