/** * Initialise */ protected function init() { $client = new Curl(); $client->setVerifyPeer(false); $client->setOption(CURLOPT_SSLVERSION, 3); $this->browser = new Browser($client); }
/** * Send the request */ public function send() { // prepare client $curl = new Curl(); $curl->send($this->request, $this->response); $this->sent = true; }
protected function getCurlInstance() { $curl = new Curl(); foreach ($this->getCurlOptions() as $option => $value) { $curl->setOption($option, $value); } return $curl; }
/** * Client constructor. * * @param array $options */ public function __construct(array $options = []) { $this->verifyArray($options, ['scheme', 'host', 'secret']); $this->options = array_replace_recursive(['timeout' => 30], $options); $client = new Curl(); $client->setTimeout($this->options['timeout']); $this->browser = new Browser($client); }
/** * resolve curl configuration * @return Curl */ private function prepareCurl() { $curl = new Curl(); $curl->setOption(CURLOPT_USERAGENT, 'Taiga-PHP-SDK'); $curl->setVerifyPeer(false); $curl->setTimeout(200); return $curl; }
/** * Register any application services. * * @return void */ public function register() { $this->app->bind('http.client', function ($app) { $client = new Curl(); $client->setTimeout(120); return new Browser($client); }); }
/** * resolve curl configuration * @return Curl */ private function prepareCurl() { $curl = new Curl(); $curl->setOption(CURLOPT_USERAGENT, 'HypeMailchimp'); $curl->setVerifyPeer(false); $curl->setTimeout($this->config['timeout']); return $curl; }
public function perform($url) { $curl = new Curl(); $curl->setTimeout(30); $curl->setProxy($this->proxy); $browser = new Browser($curl); return $this->serializer->decode($browser->post($url)->getContent(), 'xml'); }
/** * @param string $accessToken * @param Browser $browser (optional) * @param ListenerInterface $listener (optional) * @param ExceptionInterface $exception (optional) */ public function __construct($accessToken, Browser $browser = null, ListenerInterface $listener = null, ExceptionInterface $exception = null) { $curl = new Curl(); $curl->setTimeout(10); // 10 seconds $this->browser = $browser ?: new Browser($curl); $this->browser->addListener($listener ?: new BuzzOAuthListener($accessToken)); $this->exception = $exception; }
/** * Initialise */ protected function init() { $client = new Curl(); $client->setVerifyPeer(false); $client->setOption(CURLOPT_USERPWD, $this->options['key'] . ':'); if (isset($this->options['timeout'])) { $client->setTimeout($this->options['timeout']); } $this->browser = new Browser($client); }
public function __construct(Response $response, Request $request, Curl $client) { $this->response = $response; $request->setProtocolVersion(1.1); $request->addHeader('Content-Type: application/json'); $this->request = $request; $client->setTimeout(5); $client->setIgnoreErrors(true); $this->client = $client; }
public function initBrowser($curlOptions) { $curl = new Curl(); foreach ($curlOptions as $key => $option) { $curl->setOption(constant(strtoupper($key)), $option); } //to avoid ssl certificate error $curl->setVerifyPeer(false); $this->browser = new Browser($curl); }
/** * Constructs the client. * * @param string $url The base URL for WebDriver server * * @param Buzz\Client\ClientInterface $client The client to use for * requesting the WebDriver server */ public function __construct($url, ClientInterface $client = null) { if (null === $client) { $client = new Curl(); $client->setTimeout(self::DEFAULT_TIMEOUT); $client->setMaxRedirects(0); } $this->url = $url; $this->client = $client; $this->browsers = array(); }
public function __construct($token, $roomId) { if (empty($token) || empty($roomId)) { throw \Exception('token or room id not configure'); } $this->roomId = $roomId; $curl = new Curl(); $curl->setTimeout(15); $this->client = new Client(new OAuth2($token), new Browser($curl)); $this->roomApi = new RoomAPI($this->client); }
/** * @param string $binaryImage * @param string $filename * @param int $expire * * @return Response */ public function call($binaryImage, $filename, $expire) { $response = new Response(); $image = new FormUpload(); $image->setFilename($filename); $image->setContent($binaryImage); $request = $this->buildRequest($image, $expire); $this->client->setOption(CURLOPT_TIMEOUT, 10000); $this->client->send($request, $response); return $this->processResponse($response); }
/** * @return Curl */ public static function createCurl() { $client = new Curl(); //reaction to the ssl3.0 shutdown from paypal //https://www.paypal-community.com/t5/PayPal-Forward/PayPal-Response-to-SSL-3-0-Vulnerability-aka-POODLE/ba-p/891829 //http://googleonlinesecurity.blogspot.com/2014/10/this-poodle-bites-exploiting-ssl-30.html $client->setOption(CURLOPT_SSL_CIPHER_LIST, 'TLSv1'); //There is a constant for that CURL_SSLVERSION_TLSv1, but it is not present on some versions of php. $client->setOption(CURLOPT_SSLVERSION, $curlSslVersionTlsV1 = 1); return $client; }
/** * Class constructor. * * @param string $consumerKey * @param string $consumerSecret * @param string|null $accessToken * @param string|null $accessTokenSecret * @param string|null $apiUrl * @param string|null $proxy * @param int|null $timeout */ public function __construct($consumerKey, $consumerSecret, $accessToken = null, $accessTokenSecret = null, $apiUrl = null, $proxy = null, $timeout = null) { $this->consumerKey = $consumerKey; $this->consumerSecret = $consumerSecret; $this->accessToken = $accessToken; $this->accessTokenSecret = $accessTokenSecret; $this->apiUrl = $apiUrl ?: self::BASE_URL . '/1.1/'; $curl = new Curl(); $curl->setTimeout($timeout); $curl->setProxy($proxy); $this->browser = new Browser($curl); }
/** * Tells if the data looks like spam * * @param array $data * @return boolean */ public function isSpam(array $data) { $data['blog'] = $this->blogUrl; $request = new Message\Request('POST', '/1.1/comment-check', $this->getHost()); $request->setContent(http_build_query($data)); $request->addHeader('Content-Type: application/x-www-form-urlencoded'); $request->addHeader(sprintf('Content-Length: %d', strlen($request->getContent()))); $response = new Message\Response(); $client = new Client\Curl(); $client->send($request, $response); return 'true' == $response->getContent(); }
public function mine(\DateTime $fromDate, $period) { // $fromDate = (new Literal\DateTime($fromDate))->dumpValue('text'); $query = <<<QUERY select ?subscriber ?subscriptionPeriod where { ?subscriber tal:subscriptionApplied ?subscription . ?subscription tal:subscriptionType tal:SubscriptionForumPosts . ?subscription tal:subscriptionPeriod ?subscriptionPeriod . } QUERY; echo $query; $result = $this->endpoint->query($query); $subscriptions = []; foreach ($result as $element) { $subscriptions[$element->subscriber->getUri()] = ['period' => $element->subscriptionPeriod->getValue()]; } $response = $this->httpClient->submit('http://www.talaka.by/forum/extensions/talaka_integration/get_new_topics.php', ['from' => $fromDate->getTimestamp()], 'GET'); $data = json_decode($response->getContent(), true); foreach ($data as $userURI => $userInfo) { if (array_key_exists($userURI, $subscriptions)) { if ($subscriptions[$userURI]['period'] != $period) { $this->logger->addDebug('Skip user for period (' . $period . ')' . $userURI); continue; } } // var_dump($userURI); // var_dump($userInfo['userName']); $topics = $userInfo['topics']; $this->logger->addInfo('User: '******'Topics count: ' . is_array($topics) ? count($topics) : 'NOT ARRAY!'); foreach ($topics as $topicURI => $topicName) { $brief = new ForumTopicBrief(); $brief->setCreationDate($fromDate); $brief->setSubscriber($userURI); $entity = new Generic(); $entity->setOrigin($topicURI); $entity->setRdfNamespace('talforumtopic'); $entity->name = $topicName; $brief->setEntity($entity); (yield $brief); } // foreach ($element as $field => $value) { // $this->briefPropertySetter->setBriefProperty($brief, $field, $value); // } } }
protected function setUp() { $client = new Curl(); $client->setTimeout(30); $this->browser = new Browser($client); $clientId = $this->getEnvironmentVariable('MICROSOFT_OAUTH_CLIENT_ID'); $clientSecret = $this->getEnvironmentVariable('MICROSOFT_OAUTH_CLIENT_SECRET'); $cache = new ArrayCache(); $accessTokenCache = new AccessTokenCache($cache); $accessTokenProvider = new AccessTokenProvider($this->browser, $clientId, $clientSecret); $accessTokenProvider->setCache($accessTokenCache); $this->translator = new MicrosoftTranslator($this->browser, $accessTokenProvider); }
/** * Initializes context with parameters from behat.yml. * * @param array $parameters */ public function __construct(array $parameters) { $this->parameters = $parameters; $curlBuzzClient = new Curl(); $curlBuzzClient->setTimeout(30); $curlBuzzClient->setOption(CURLOPT_SSL_VERIFYHOST, 0); $curlBuzzClient->setOption(CURLOPT_SSL_VERIFYPEER, 0); $this->browser = new Browser($curlBuzzClient); $this->useContext('secure', new SecureContext()); $this->useContext('activity', new ActivityContext()); $this->useContext('group', new GroupContext()); $this->useContext('poll', new PollContext()); }
/** * Performs an "Had" action on facebook app * * <code> * curl * -F 'access_token=xxxxxxxxxxxxxxxx' * -F 'cocktail=http://just-had-a-cocktail.pagodabox.com/cocktail/yyyyyyy' * 'https://graph.facebook.com/me/lmammino-jhac:had' * </code> * * @param $cocktailUrl */ public function hadCocktail($cocktailUrl, $timestamp = NULL) { $request = new FormRequest(Request::METHOD_POST, 'me/lmammino-jhac:had', self::$GRAPH_HOST); $request->setField('access_token', $this->accessToken); $request->setField('cocktail', $cocktailUrl); if ($timestamp) { $date = date('c', $timestamp); $request->setField('start_time', $date); $request->setField('end_time', $date); } $response = new Response(); $this->buzz->send($request, $response); return json_decode($response->getContent()); }
public function sendRequest() { // new Request $request = new Request($this->requestType, $this->resource, $this->host); // add headers $request->addHeaders($this->headers); // add body $request->setContent($this->body); // prepare client $response = new Response(); $curl = new Curl(); $curl->send($request, $response); $this->request = $request; $this->response = $response; }
/** * @param Doctrine\Common\Collections\Collection $collection * @throws AntiMattr\Sears\Exception\Connection\ConnectionException * @throws AntiMattr\Sears\Exception\Http\BadRequestException * @throws AntiMattr\Sears\Exception\IntegrationException */ public function updateShipments(Collection $collection) { $handler = $this->requestHandlerFactory->createRequestHandler('updateShipments'); $resource = sprintf('/SellerPortal/api/oms/asn/v5?email=%s&password=%s', $this->email, $this->password); $request = $this->messageFactory->createRequest('PUT', $resource, $this->host); $integrationException = null; try { $handler->bindCollection($request, $collection); } catch (IntegrationException $e) { $integrationException = $e; } $this->updateHeaders($request); $requestString = $request->__toString(); $this->log($requestString); $response = $this->messageFactory->createResponse(); try { $this->buzz->send($request, $response); } catch (ClientException $e) { $subject = $e->getMessage(); throw new ConnectionException($subject); } $responseString = $response->__toString(); $this->log($responseString); if ($integrationException) { throw $integrationException; } }
/** * @return Curl */ public static function createCurl() { $client = new Curl(); // Reaction to the ssl3.0 shutdown from paypal // https://www.paypal-community.com/t5/PayPal-Forward/PayPal-Response-to-SSL-3-0-Vulnerability-aka-POODLE/ba-p/891829 // http://googleonlinesecurity.blogspot.com/2014/10/this-poodle-bites-exploiting-ssl-30.html // Do not use the Cipher List for NSS // https://github.com/paypal/sdk-core-php/blob/namespace-5.3/lib/PayPal/Core/PPHttpConfig.php#L51 $curl = curl_version(); $sslVersion = isset($curl['ssl_version']) ? $curl['ssl_version'] : ''; if (false === strpos($sslVersion, "NSS/")) { $client->setOption(CURLOPT_SSL_CIPHER_LIST, 'TLSv1'); } //There is a constant for that CURL_SSLVERSION_TLSv1, but it is not present on some versions of php. $client->setOption(CURLOPT_SSLVERSION, $curlSslVersionTlsV1 = 1); return $client; }
public static function setUpBeforeClass() { if (false == isset($GLOBALS['AKAMAI_CLIENT_TOKEN'])) { throw new \PHPUnit_Framework_SkippedTestError('These tests require AKAMAI_CLIENT_TOKEN to be set in phpunit.xml'); } if (false == isset($GLOBALS['AKAMAI_ACCESS_TOKEN'])) { throw new \PHPUnit_Framework_SkippedTestError('These tests require AKAMAI_ACCESS_TOKEN to be set in phpunit.xml'); } if (false == isset($GLOBALS['AKAMAI_CLIENT_SECRET'])) { throw new \PHPUnit_Framework_SkippedTestError('These tests require AKAMAI_CLIENT_SECRET to be set in phpunit.xml'); } if (false == isset($GLOBALS['AKAMAI_BASEURL'])) { throw new \PHPUnit_Framework_SkippedTestError('These tests require AKAMAI_BASEURL to be set in phpunit.xml'); } $curl = new Curl(); $curl->setTimeout(10); self::$client = new Client($curl, $GLOBALS['AKAMAI_CLIENT_TOKEN'], $GLOBALS['AKAMAI_CLIENT_SECRET'], $GLOBALS['AKAMAI_ACCESS_TOKEN'], $GLOBALS['AKAMAI_BASEURL']); }
public function send(RequestInterface $request, MessageInterface $response, array $options = array()) { try { parent::send($request, $response, $options); } catch (RuntimeException $e) { // Catch but do not do anything as we consider the request to be ~ asynchronous if (isset($this->logger)) { $this->logger->notice("An issue occurred while handling HttpCache purge: {$e->getMessage()}."); } } }
public function getCurl($i = null) { if (null === $i) { return parent::getCurl(); } elseif (isset($this->queue[$i])) { list($request, $response, $curl) = $this->queue[$i]; return $curl; } else { throw new \InvalidArgumentException(sprintf('There is no cURL handler queued at position %s.', $i)); } }
/** * Send API request to mailchimp * * @param string $apiCall mailchimp method * @param string $payload Request information * @param boolean $export mailchimp export api * * @return json */ protected function makeRequest($apiCall, $payload, $export = false) { $payload['apikey'] = $this->apiKey; $payload['id'] = $this->listId; if ($export) { $url = $this->dataCenter . $apiCall; } else { $url = $this->dataCenter . '1.3/?method=' . $apiCall; } $curl = new Curl(); $curl->setOption(CURLOPT_USERAGENT, 'MZMailChimpBundle'); // Set long timeout for Export API to allow for larger responses if ($export) { $curl->setOption(CURLOPT_TIMEOUT, 600); } else { $curl->setOption(CURLOPT_TIMEOUT, 30); } $browser = new Browser($curl); $response = $browser->post($url, array(), http_build_query($payload)); return $response->getContent(); }
/** * @param array $parameters * * @return array */ protected function doHttpRequest($parameters) { $request = new Request(RequestInterface::METHOD_POST, self::OAUTH2_ACCESS_TOKEN_URL); $response = new Response(); $contentParameters = ['client_id' => $this->configManager->get('oro_google_integration.client_id'), 'client_secret' => $this->configManager->get('oro_google_integration.client_secret')]; $parameters = array_merge($contentParameters, $parameters); $content = http_build_query($parameters, '', '&'); $headers = ['Content-length: ' . strlen($content), 'content-type: application/x-www-form-urlencoded', 'user-agent: oro-oauth']; $request->setHeaders($headers); $request->setContent($content); $this->httpClient->send($request, $response); return $this->getResponseContent($response); }