コード例 #1
0
ファイル: BuzzAdapter.php プロジェクト: sumocoders/vtiger-api
 /**
  * Send the request
  *
  * @param RequestInterface $request The request to send
  *
  * @return MessageInterface The response
  */
 protected function send(RequestInterface $request)
 {
     $response = new Response();
     $client = new FileGetContents();
     $client->send($request, $response);
     return $response;
 }
コード例 #2
0
ファイル: FileGetContentsTest.php プロジェクト: kingsj/core
 /**
  * @dataProvider provideInvalidHosts
  */
 public function testSendToInvalidUrl($host)
 {
     $this->setExpectedException('RuntimeException');
     $request = new Message\Request();
     $request->fromUrl('http://' . $host . ':12345');
     $response = new Message\Response();
     $client = new FileGetContents();
     $client->setTimeout(0.05);
     $client->send($request, $response);
 }
コード例 #3
0
ファイル: FormDriver.php プロジェクト: scaytrase/websms-php
 private function doRealRequest($url, array $options)
 {
     $request = new FormRequest(Request::METHOD_POST);
     $request->fromUrl($url);
     $request->setFields($options);
     $response = new Response();
     $client = new FileGetContents();
     $client->send($request, $response);
     return $response->getContent();
 }
コード例 #4
0
ファイル: HttpClient.php プロジェクト: tlongren/RingCentral
 /**
  * @param string $host
  * @param string $resource
  * @return string
  *   Return the response body from the HTTP request
  */
 public function doRequest($host, $resource)
 {
     if (!($cookieJar = $this->cache->fetch('wesnick.ringcentral.cookies'))) {
         $cookieJar = new CookieJar();
     }
     $client = new FileGetContents($cookieJar);
     $request = new Request(Request::METHOD_GET, $resource, $host);
     $response = new Response();
     $client->setVerifyPeer(false);
     $client->send($request, $response);
     $this->cache->save('wesnick.ringcentral.cookies', $client->getCookieJar());
     return $response->getContent();
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function createClient(array $config = [])
 {
     if (!class_exists('Http\\Adapter\\Buzz\\Client')) {
         throw new \LogicException('To use the Buzz adapter you need to install the "php-http/buzz-adapter" package.');
     }
     $client = new FileGetContents();
     $options = $this->getOptions($config);
     $client->setTimeout($options['timeout']);
     $client->setVerifyPeer($options['verify_peer']);
     $client->setVerifyHost($options['verify_host']);
     $client->setProxy($options['proxy']);
     return new Adapter($client, $this->messageFactory);
 }
コード例 #6
0
 public function getBrowser($_client, $_timeout)
 {
     switch ($_client) {
         case 'curl':
             $client = new Curl();
             break;
         case 'file_get_contents':
             $client = new FileGetContents();
             break;
         default:
             throw new \Exception('Client type "' . $_client . '" is invalid');
     }
     $client->setTimeout($_timeout);
     return new Browser($client);
 }
コード例 #7
0
ファイル: JsonDriver.php プロジェクト: scaytrase/websms-php
 public function doSendRequest(array $options)
 {
     $request = new FormRequest(Request::METHOD_POST);
     $request->fromUrl(static::HTTP_AccessPoint_Send);
     $request->setFields(array('json' => json_encode($options)));
     $response = new Response();
     $client = new FileGetContents();
     $client->send($request, $response);
     $json = $response->getContent();
     $status = json_decode($json, true);
     if (!isset($status[static::Error_Code])) {
         throw new InvalidResponseException('JSON response does not contain response code');
     }
     $normalized_status = $status;
     $normalized_status[self::NORMALIZED_MESSAGE] = $status[self::Error_Message];
     $normalized_status[self::NORMALIZED_CODE] = $status[self::Error_Code];
     return $normalized_status;
 }
コード例 #8
0
 /**
  * @return Curl|FileGetContents
  */
 public static function getClient()
 {
     if (in_array('curl', get_loaded_extensions())) {
         $client = new Curl();
     } else {
         $client = new FileGetContents();
     }
     $client->setVerifyPeer(false);
     $client->setVerifyHost(false);
     return $client;
 }