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


PHP Client::request方法代码示例

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


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

示例1: logInAs

 public function logInAs($username)
 {
     $crawler = $this->client->request('GET', '/login');
     $form = $crawler->filter('button[type=submit]')->form();
     $data = ['_username' => $username, '_password' => 'mypassword'];
     $this->client->submit($form, $data);
 }
开发者ID:jjanvier,项目名称:wallabag,代码行数:7,代码来源:WallabagAnnotationTestCase.php

示例2: doLogin

 /**
  * Do login with username
  *
  * @param string $username
  */
 private function doLogin($username = 'admin')
 {
     $crawler = $this->client->request('GET', $this->getUrl('fos_user_security_login', array()));
     $form = $crawler->selectButton('_submit')->form(array('_username' => $username, '_password' => 'qwerty'));
     $this->client->submit($form);
     $this->assertTrue($this->client->getResponse()->isRedirect());
     $this->client->followRedirects();
 }
开发者ID:alienpham,项目名称:portfolio,代码行数:13,代码来源:AccessTest.php

示例3: search

 /**
  * @param string     $query
  * @param array|null $args
  *
  * @return mixed
  *
  * @throws AlgoliaException
  */
 public function search($query, $args = null)
 {
     if ($args === null) {
         $args = array();
     }
     $args['query'] = $query;
     return $this->client->request($this->context, 'POST', '/1/places/query', array(), array('params' => $this->client->buildQuery($args)), $this->context->readHostsArray, $this->context->connectTimeout, $this->context->searchTimeout);
 }
开发者ID:algolia,项目名称:algoliasearch-client-php,代码行数:16,代码来源:PlacesIndex.php

示例4: request

 public function request($method, $path, $data = null, $raw = false)
 {
     $start = microtime(true);
     $response = $this->client->request($method, $path, $data, $raw);
     $duration = microtime(true) - $start;
     $this->requests[] = array('duration' => $duration, 'method' => $method, 'path' => rawurldecode($path), 'request' => $data, 'request_size' => strlen($data), 'response_status' => $response->status, 'response' => $response->body, 'response_headers' => $response->headers);
     $this->totalDuration += $duration;
     return $response;
 }
开发者ID:katopenzz,项目名称:openemr,代码行数:9,代码来源:LoggingClient.php

示例5: run

 public function run()
 {
     $urls = is_array($this->url) ? $this->url : [$this->url];
     foreach ($urls as $url) {
         $response = $this->client->request('GET', $url, ['headers' => ['User-Agent' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)']]);
         $contents[] = (string) $response->getBody();
     }
     return $contents;
 }
开发者ID:GCwouter,项目名称:Samantha,代码行数:9,代码来源:BaseCrawler.php

示例6: request

 public function request($url, array $parameters = array(), $method = Client::GET, array $headers = array(), array $options = array())
 {
     $key = $this->makeCacheKey($method, $url, $parameters);
     if ($key) {
         if ($this->cache->contains($key)) {
             return $this->cache->fetch($key);
         }
     }
     $result = $this->client->request($url, $parameters, $method, $headers, $options);
     if ($key) {
         $this->cache->save($key, $result, $this->lifetime);
     }
     return $result;
 }
开发者ID:socialconnect,项目名称:common,代码行数:14,代码来源:Cache.php

示例7: add

 public function add(Request $request)
 {
     // Ask if we are supplying our own data or requesting it from the server
     if ($request->has('remote') && ($request->remote = 'true')) {
         $client = new Client();
         $res = $client->request('GET', 'http://fsvaos.net/api/central/aircraft', ['query' => ['icao' => $request->icao]])->getBody();
         // Add the airport to the database
         $data = json_decode($res, true);
         $aircraft = new Aircraft();
         //return dd($data);
         $aircraft->name = $data[0]['name'];
         $aircraft->icao = $data[0]['icao'];
         $aircraft->maxgw = $data[0]['maxgw'];
         $aircraft->maxpax = $data[0]['maxpax'];
         $aircraft->range = $data[0]['range'];
         $aircraft->registration = $request->input('registration');
         $aircraft->enabled = true;
         $aircraft->hub = $request->input('hub');
         $aircraft->save();
     } else {
         // insert manual entry system.
         $aircraft = new Aircraft();
         //return dd($data);
         $aircraft->name = $request->input('name');
         $aircraft->icao = $request->input('icao');
         $aircraft->maxgw = $request->input('maxgw');
         $aircraft->maxpax = $request->input('maxpax');
         $aircraft->range = $request->input('range');
         $aircraft->registration = $request->input('registration');
         $aircraft->enabled = true;
         $aircraft->hub = $request->input('hub');
         $aircraft->save();
     }
 }
开发者ID:CardinalHorizon,项目名称:VAOS,代码行数:34,代码来源:FleetAPI.php

示例8: assertPutFails

 /**
  * assert that putting a fetched resource fails
  *
  * @param string $url    url
  * @param Client $client client to use
  *
  * @return void
  */
 public function assertPutFails($url, $client)
 {
     $client->request('GET', $url);
     $client->put($url, $client->getResults());
     $response = $client->getResponse();
     $this->assertEquals(405, $response->getStatusCode());
     $this->assertEquals('GET, HEAD, OPTIONS', $response->headers->get('Allow'));
 }
开发者ID:alebon,项目名称:graviton,代码行数:16,代码来源:RestTestCase.php

示例9: testSuccess

 public function testSuccess()
 {
     $this->mockStaticMethod('\\MWHttpRequest', 'canMakeRequests', true);
     $requestMock = $this->getMock('\\CurlHttpRequest', ['execute', 'getContent'], ['http://example.com'], '', false);
     $requestMock->expects($this->once())->method('getContent')->willReturn('{}');
     $this->mockStaticMethod('\\Http', 'request', $requestMock);
     $client = new Client('http://example.com', 'id', 'secret');
     $this->assertInternalType('object', $client->request('resource', [], [], []));
 }
开发者ID:yusufchang,项目名称:app,代码行数:9,代码来源:ClientTest.php

示例10: testDeleteReferenced

 public function testDeleteReferenced()
 {
     $page = $this->documentManager->create('page');
     $page->setStructureType('hotel_page');
     $page->setTitle('Hotels page');
     $page->setResourceSegment('/hotels');
     $page->getStructure()->bind(['hotels' => [$this->hotel1->getUuid(), $this->hotel2->getUuid()]]);
     $this->documentManager->persist($page, 'de', ['parent_path' => '/cmf/sulu_io/contents']);
     $this->documentManager->flush();
     $this->client->request('DELETE', '/snippets/' . $this->hotel1->getUuid() . '?_format=text');
     $response = $this->client->getResponse();
     $this->assertEquals(409, $response->getStatusCode());
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:13,代码来源:SnippetControllerTest.php

示例11: request

 /**
  * Execute a request on this resource
  *
  * @param  mixed $scope
  * @param  mixed $data
  * @return mixed
  */
 public function request($method, $scope = null, $data = null)
 {
     if (is_array($scope)) {
         $data = $scope;
         $scope = null;
     }
     $url = $scope ? $this->url . '/' . ltrim($scope, '/') : $this->url;
     $result = self::$client->request($method, $url, $data);
     if (!$scope && $result instanceof Resource) {
         // TODO: how should POST be handled here?
         foreach ($result->data() as $key => $value) {
             self::offsetSet($key, $value);
         }
     }
     return $scope ? $result : $this;
 }
开发者ID:thisislawatts,项目名称:schema-php-client,代码行数:23,代码来源:Resource.php

示例12: verify

 /**
  * Calls the reCAPTCHA siteverify API to verify whether the user passes
  * CAPTCHA test.
  *
  * @param string $response The value of 'g-recaptcha-response' in the submitted form.
  * @param string $remoteIp The end user's IP address.
  * @return Response Response from the service.
  */
 public function verify($response, $remoteIp = null)
 {
     // Discard empty solution submissions
     if (empty($response)) {
         $recaptchaResponse = new Response(false, array('missing-input-response'));
         return $recaptchaResponse;
     }
     $q = [];
     $q['secret'] = $this->secret;
     $q['response'] = $response;
     $q['remoteip'] = $remoteIp;
     try {
         $recaptchaResponse = $this->client->request("POST", null, ['form_params' => $q]);
     } catch (\GuzzleHttp\Exception\RequestException $ex) {
         $recaptchaResponse = $ex->getResponse();
     }
     return Response::fromJson($recaptchaResponse->getBody()->getContents());
 }
开发者ID:reneszabo,项目名称:acf-composer-recaptcha,代码行数:26,代码来源:ReCaptcha.php

示例13: browseFrom

 /**
  * @param string     $query
  * @param array|null $params
  * @param $cursor
  *
  * @return mixed
  */
 public function browseFrom($query, $params = null, $cursor = null)
 {
     if ($params === null) {
         $params = [];
     }
     foreach ($params as $key => $value) {
         if (gettype($value) == 'array') {
             $params[$key] = json_encode($value);
         }
     }
     if ($query != null) {
         $params['query'] = $query;
     }
     if ($cursor != null) {
         $params['cursor'] = $cursor;
     }
     return $this->client->request($this->context, 'GET', '/1/indexes/' . $this->urlIndexName . '/browse', $params, null, $this->context->readHostsArray, $this->context->connectTimeout, $this->context->readTimeout);
 }
开发者ID:jobizzness,项目名称:Jobekunda,代码行数:25,代码来源:Index.php

示例14: testRequestThrowsExpectedExceptionWhenResponseContainsErrorFlag

 /**
  * testRequestThrowsExpectedExceptionWhenResponseContainsErrorFlag
  *
  * @return void
  * @covers \QafooLabs\RestClient\RemoteException
  * @expectedException \QafooLabs\RestClient\RemoteException
  */
 public function testRequestThrowsExpectedExceptionWhenResponseContainsErrorFlag()
 {
     $this->writeTestPath(array('error' => true, 'type' => 42, 'message' => 'A message'));
     $client = new Client($this->server);
     $client->request('GET', $this->path);
 }
开发者ID:qafoolabs,项目名称:restclient,代码行数:13,代码来源:ClientTest.php

示例15: getEvents

 /**
  * @param  string device
  * @param  string query
  * @return json events
  */
 public function getEvents($device, $query)
 {
     $response = $this->client->request('GET', 'http://api.thingsee.com/v2/events/' . Config::get('thingsee.' . $device . '') . $query, ['headers' => ['Authorization' => 'Bearer ' . $this->accountAuthToken]]);
     return json_decode($response->getBody(), true);
 }
开发者ID:Tampere,项目名称:Thingsee-API,代码行数:10,代码来源:ThingseeAPI.php


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