/** * Configures the adapter for authentication against the RoboWhois API. */ protected function getDefaultAdapter() { $adapter = new Browser(); $client = new \Buzz\Client\Curl(); $client->setTimeout(5); $adapter->setClient($client); return $adapter; }
/** * Send request and generate response. * * @param Bool secure * * @throws UniversalAnalytics\Exception\InvalidRequestException * * @return Response */ public function send($secure = true) { $buzzBrowser = new Browser(); $buzzBrowser->setClient(new Curl()); $base = $secure ? $this->base_ssl : $this->base; $buzzResponse = $buzzBrowser->submit($base, $this->attributes, RequestInterface::METHOD_POST, array()); return new Response($buzzResponse); }
/** * Send request and generate response * * @param Bool secure * @throws UniversalAnalytics\Exception\InvalidRequestException * @return Response */ public function send($secure = true) { $headers = array(); if (is_null($this->user_agent_string) === false) { $headers['User-Agent'] = $this->user_agent_string; } $buzzBrowser = new Browser(); $buzzBrowser->setClient(new Curl()); $base = $secure ? $this->base_ssl : $this->base; $buzzResponse = $buzzBrowser->submit($base, $this->attributes, RequestInterface::METHOD_POST, $headers); return new Response($buzzResponse); }
/** * @return Response */ function announce() { $headers = array(); $headers['User-Agent'] = $this->torrent_client->getUserAgent(); $headers = array_merge($headers, (array) $this->torrent_client->getExtraHeader()); $browser = new Browser(); $browser->setClient(new \Buzz\Client\Curl()); /** @var $response \Buzz\Message\Response */ $response = $browser->get($this->generateUrl(), $headers); $this->decompressContent($response); return new Response($response->getContent()); }
public function testCachedBrowserClient() { $currentClient = $this->browser->getClient(); $arrayCache = new ArrayCache(); $cachedClient = new CachedClient($currentClient, $arrayCache); $this->browser->setClient($cachedClient); for ($i = 1; $i <= 3; $i++) { $this->translator->translate('This is a test', 'nl'); } $this->assertLessThanOrEqual(2, $cachedClient->getMisses()); // at most one for the access token, one for the translation $this->assertSame(2, $cachedClient->getHits()); $this->browser->setClient($currentClient); }
/** * Returns flash converted to html5 * * @param string $filename * @return boolean|string */ public function convert($filename, $jsonOnly = false) { $content = file_get_contents($filename); if (false === $content) { return false; } $request = json_encode(array("apiVersion" => $this->apiVersion, "method" => "swiffy.convertToHtml", "params" => array("client" => $this->userAgent, "input" => $this->base64safe_encode($content)))); $browser = new Browser(); $client = new Curl(); $client->setTimeout(self::TIMEOUT); $browser->setClient($client); $response = $browser->post($this->apiUrl, array("Content-Type" => "application/json"), $request); $response = json_decode($response->getContent(), true); if (array_key_exists("error", $response)) { return false; } $result = $this->base64safe_decode($response["result"]["response"]["output"]); if ($jsonOnly) { $result = $this->getJson($result); } return $result; }
private function getFriendsFacebook($user) { ini_set("display_errors", 1); $url = 'https://graph.facebook.com/'; $url .= $user->getFacebookuid(); $url .= '/friends?fields=name,picture,username&access_token='; $url .= $user->getFacebookname(); $browser = new Browser(); $browser->setClient(new Curl()); $response = $browser->get($url); $data = $response->getContent(); $return = array(); $dataJSON = json_decode($data); foreach ($dataJSON->data as $item) { $object['id'] = $item->id; $object['name'] = $item->name; if (isset($item->username)) { $object['username'] = $item->username; } $object['picture'] = $item->picture->data->url; $return[] = $object; } return $return; }
<?php require __DIR__ . '/vendor/autoload.php'; use Buzz\Browser; use Buzz\Client\Curl; $browser = new Browser(); $client = new Curl(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/CAcerts/BuiltinObjectToken-EquifaxSecureCA.crt"); $client->setMaxRedirects(0); $browser->setClient($client); $response = $browser->get('https://thepiratebay.mn'); echo $response;
<?php require '../vendor/autoload.php'; use Buzz\Browser; use Buzz\Client\Curl; use Buzz\Listener\DigestAuthListener; $username = '******'; $password = '******'; // // This URL will Authenticate usernames user1 through user9, password is the same as the username. // $url = 'http://test.webdav.org/auth-digest/'; // Create Curl Client $curl = new Curl(); $browser = new Browser(); $browser->setClient($curl); // Create DigestAuthListener $browser->addListener(new DigestAuthListener($username, $password)); // // This URL will Authenticate any username and password that matches those in the URL. // It requires the Browser/Client to respond with the same Cookie in order to Authenticate. // // $url = 'http://httpbin.org/digest-auth/auth-int/' . $username . '/' . $password; $response = $browser->get($url); echo $response; $statusCode = $response->getStatusCode(); if ($statusCode == 401) { $response = $browser->get($url); } echo $response;
/** * * This code is copied from Ctsmedia\Phpbb\BridgeBundle\PhpBB\Connector * @return Browser */ protected function initContaoRequest() { // Init Request $client = new Curl(); $client->setMaxRedirects(0); $browser = new Browser(); $browser->setClient($client); $cookieListener = new CookieListener(); $browser->addListener($cookieListener); return $browser; }
/** * @return Browser */ protected function initForumRequest($force = false) { // Init Request $client = new Curl(); $client->setMaxRedirects(0); $browser = new Browser(); $browser->setClient($client); $cookieListener = new CookieListener(); $browser->addListener($cookieListener); // We need to make sure that the if the original Request is already coming from the forum, we then are not // allowed to send a request to the forum so we create a login loop for example. if ($force === false && System::getContainer()->get('request_stack')->getCurrentRequest() && System::getContainer()->get('request_stack')->getCurrentRequest()->headers->get('x-requested-with') == 'ContaoPhpbbBridge') { System::log('Bridge Request Recursion detected', __METHOD__, TL_ERROR); throw new TooManyRequestsHttpException(null, 'Internal recursion Bridge requests detected'); } return $browser; }
/** * @param ClientInterface $client Client to be used by the Browser instance */ public function setClient(ClientInterface $client) { $this->browser->setClient($client); }