当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP_Request2::setAdapter方法代码示例

本文整理汇总了PHP中HTTP_Request2::setAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP_Request2::setAdapter方法的具体用法?PHP HTTP_Request2::setAdapter怎么用?PHP HTTP_Request2::setAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTP_Request2的用法示例。


在下文中一共展示了HTTP_Request2::setAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRequest

 /**
  * @param string $user
  * @param string $apiKey
  *
  * @return Request2
  */
 public function getRequest($user, $apiKey)
 {
     if ($this->req === null) {
         $this->req = new Request2();
         $this->req->setAdapter('curl')->setHeader('user-agent', 'Services_Librato');
     }
     $this->req->setAuth($user, $apiKey);
     return $this->req;
 }
开发者ID:till,项目名称:services_librato,代码行数:15,代码来源:Librato.php

示例2: testSetRequest

 public function testSetRequest()
 {
     $newswire = new Newswire('apikey');
     $req = new \HTTP_Request2();
     $req->setAdapter('mock');
     $this->assertInstanceOf('PEAR2\\Services\\NYTimes\\Newswire', $newswire->accept($req));
 }
开发者ID:pear2,项目名称:services_nytimes,代码行数:7,代码来源:BaseTest.php

示例3: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->mock = new HTTP_Request2_Adapter_Mock();
     $request = new HTTP_Request2();
     $request->setAdapter($this->mock);
     $this->validator = new Services_W3C_CSSValidator($request);
 }
开发者ID:pear,项目名称:services_w3c_cssvalidator,代码行数:13,代码来源:Services_W3C_CSSValidatorTest.php

示例4: request

 private function request($method, $path, $params = array())
 {
     $url = $this->api . rtrim($path, '/') . '/';
     if (!strcmp($method, "POST")) {
         $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST);
         $req->setHeader('Content-type: application/json');
         if ($params) {
             $req->setBody(json_encode($params));
         }
     } else {
         if (!strcmp($method, "GET")) {
             $req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
             $url = $req->getUrl();
             $url->setQueryVariables($params);
         } else {
             if (!strcmp($method, "DELETE")) {
                 $req = new HTTP_Request2($url, HTTP_Request2::METHOD_DELETE);
                 $url = $req->getUrl();
                 $url->setQueryVariables($params);
             }
         }
     }
     $req->setAdapter('curl');
     $req->setConfig(array('timeout' => 30));
     $req->setAuth($this->auth_id, $this->auth_token, HTTP_Request2::AUTH_BASIC);
     $req->setHeader(array('Connection' => 'close', 'User-Agent' => 'PHPPlivo'));
     $r = $req->send();
     $status = $r->getStatus();
     $body = $r->getbody();
     $response = json_decode($body, true);
     return array("status" => $status, "response" => $response);
 }
开发者ID:davidangelcb,项目名称:voice,代码行数:32,代码来源:plivo.php

示例5: addHttpMock

 protected function addHttpMock(Net_WebFinger $wf)
 {
     $this->adapter = new HTTP_Request2_Adapter_LogMock();
     $req = new HTTP_Request2();
     $req->setAdapter($this->adapter);
     $wf->setHttpClient($req);
     return $this;
 }
开发者ID:mitgedanken,项目名称:Net_WebFinger,代码行数:8,代码来源:WebFingerTestBase.php

示例6: testGetException

 /**
  * @expectedException Services_Yadis_Exception
  * @expectedExceptionMessage Invalid response to Yadis protocol received: A test error
  */
 public function testGetException()
 {
     $httpMock = new HTTP_Request2_Adapter_Mock();
     $httpMock->addResponse(new HTTP_Request2_Exception('A test error', 500));
     $http = new HTTP_Request2();
     $http->setAdapter($httpMock);
     $sy = new Services_Yadis('http://example.org/openid');
     $sy->setHttpRequest($http);
     $xrds = $sy->discover();
 }
开发者ID:pear,项目名称:services_yadis,代码行数:14,代码来源:YadisTest.php

示例7: getContents

function getContents($url, $start = 0, $userAgent = null)
{
    if ($start > 0) {
        $url .= "&start={$start}";
    }
    $http = new HTTP_Request2($url);
    $http->setAdapter('curl');
    if ($userAgent !== null) {
        $http->setHeader('User-Agent', $userAgent);
    }
    return $http->send();
}
开发者ID:shupp,项目名称:bandk,代码行数:12,代码来源:scrape.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     Yii::configure(Yii::$app, ['components' => ['user' => ['class' => 'yii\\web\\User', 'identityClass' => 'common\\models\\User'], 'p24' => ['class' => \merigold\przelewy24\src\Przelewy24Component::className(), 'merchant_id' => $this->merchant_id, 'pos_id' => $this->merchant_id, 'CRC' => $this->CRC]]]);
     Yii::$container->set('HTTP_Request2', function () {
         $response = new HTTP_Request2_Response("HTTP/1.1 200 OK", true);
         $response->appendBody($this->succesresponse);
         $mockAdapter = new HTTP_Request2_Adapter_Mock();
         $mockAdapter->addResponse($response);
         $stub = new HTTP_Request2(\merigold\przelewy24\src\Przelewy24Component::TEST_URL, HTTP_Request2::METHOD_POST);
         $stub->setAdapter($mockAdapter);
         return $stub;
     });
 }
开发者ID:merigold,项目名称:yii2-p24,代码行数:14,代码来源:Przelewy24ComponentTest.php

示例9: testShouldCompleteTransaction

 public function testShouldCompleteTransaction()
 {
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse('HTTP/1.1 200 OK');
     $request = new HTTP_Request2();
     $request->setAdapter($mock);
     $object = Payment_Process2::factory('Dummy');
     $object->login = 'unit';
     $object->password = 'test';
     $object->action = Payment_Process2::ACTION_NORMAL;
     $object->amount = 1;
     $object->setRequest($request);
     $object->setPayment($this->aValidPayment());
     $result = $object->process();
     $this->assertTrue($result instanceof Payment_Process2_Result_Dummy);
 }
开发者ID:pear,项目名称:payment_process2,代码行数:16,代码来源:Payment_Process2_DummyTest.php

示例10: http2_request

 private function http2_request($method, $path, $params)
 {
     $url = $this->api . $path;
     $http_method = \HTTP_Request2::METHOD_POST;
     if (!strcmp($method, "GET")) {
         $http_method = \HTTP_Request2::METHOD_GET;
     } else {
         if (!strcmp($method, "DELETE")) {
             $http_method = \HTTP_Request2::METHOD_DELETE;
         }
     }
     $req = new \HTTP_Request2($url, $http_method);
     if ($http_method === \HTTP_Request2::METHOD_POST && $params) {
         $req->setBody(json_encode($params));
     }
     $req->setAdapter('curl');
     $req->setConfig(array('timeout' => 30, 'ssl_verify_peer' => FALSE));
     $req->setHeader(array('Authorization' => $this->auth_token, 'Connection' => 'close', 'User-Agent' => 'CheckMobi/http2_request', 'Content-type' => 'application/json'));
     $r = $req->send();
     $status = $r->getStatus();
     $body = $r->getbody();
     $response = json_decode($body, true);
     return array("status" => $status, "response" => $response);
 }
开发者ID:tao592,项目名称:checkmobi-php,代码行数:24,代码来源:CheckMobiRest.php

示例11: mockDataProviderHelper

 public static function mockDataProviderHelper($file)
 {
     $process = self::aProcessor();
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse(self::aResponse($file));
     $request = new HTTP_Request2();
     $request->setAdapter($mock);
     $process->setRequest($request);
     return array($process);
 }
开发者ID:pear,项目名称:payment_process2,代码行数:10,代码来源:Payment_Process2_ANZTest.php

示例12: testResponseException

 public function testResponseException()
 {
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse(new HTTP_Request2_Exception('Shit happens'));
     $req = new HTTP_Request2('http://www.example.com/');
     $req->setAdapter($mock);
     try {
         $req->send();
     } catch (Exception $e) {
         $this->assertEquals('Shit happens', $e->getMessage());
         return;
     }
     $this->fail('Expected HTTP_Request2_Exception was not thrown');
 }
开发者ID:SuhitNarayan,项目名称:SuhitNarayan-SEMANTICTECH,代码行数:14,代码来源:MockTest.php

示例13: getHTTPRequest2Instance

 /**
  * Instantiates HTTP_Request2.  Abstracted for testing.
  * 
  * @see directRequest()
  * @return HTTP_Request2_Response
  */
 protected function getHTTPRequest2Instance()
 {
     // @codeCoverageIgnoreStart
     $request = new HTTP_Request2();
     $request->setAdapter('curl');
     return $request;
     // @codeCoverageIgnoreEnd
 }
开发者ID:shupp,项目名称:openid,代码行数:14,代码来源:OpenID.php

示例14: send

 /**
  * The actual method for sending requests
  *
  * @param	string	$url
  * @param	array	$headers
  * @param	array	$params
  * @return	HTTP_Request2_Response
  */
 protected function send($method, $url, array $params = array(), array $headers = array())
 {
     $headers['GData-Version'] = '2';
     $headers['User-Agent'] = 'Vivvo/' . VIVVO_VERSION . ' (' . self::$request_adapter . ') PHP/' . PHP_VERSION;
     $request = new HTTP_Request2($url);
     $request->setAdapter(self::$request_adapter);
     $request->setConfig('ssl_verify_peer', false);
     $request->setConfig('follow_redirects', true);
     $request->setHeader($headers);
     $request->setMethod($method);
     if ($method == HTTP_Request2::METHOD_POST) {
         $request->addPostParameter($params);
     }
     return $request->send();
 }
开发者ID:ahanjir07,项目名称:vivvo-dev,代码行数:23,代码来源:vivvo_ga.php

示例15: testShouldFailGracefullyOnFailedTransaction

 public function testShouldFailGracefullyOnFailedTransaction()
 {
     $response = new HTTP_Request2_Response('HTTP/1.1 200 OK');
     $response->appendBody(file_get_contents(dirname(__FILE__) . '/data/TrustCommerce/error.html'));
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse($response);
     $request = new HTTP_Request2();
     $request->setAdapter($mock);
     $object = Payment_Process2::factory('TrustCommerce');
     $object->setPayment($this->aValidPayment());
     $object->login = 'unit';
     $object->password = 'test';
     $object->amount = 1;
     $object->action = Payment_Process2::ACTION_NORMAL;
     $object->setRequest($request);
     $result = $object->process();
     $this->assertTrue($result instanceof Payment_Process2_Result_TrustCommerce);
     $this->assertSame(Payment_Process2::RESULT_OTHER, $result->getCode(), $result->getMessage());
 }
开发者ID:pear,项目名称:payment_process2,代码行数:19,代码来源:Payment_Process2_TrustCommerceTest.php


注:本文中的HTTP_Request2::setAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。