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


PHP Client::setAuth方法代码示例

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


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

示例1: getXML

 private function getXML($query, $mal = true, $account = null)
 {
     if ($mal) {
         $client = new Client();
         if (empty($account)) {
             $client->setAuth(ConnectDetails::$mal_username, ConnectDetails::$mal_password);
         } else {
             $client->setAuth($account["username"], $account["password"]);
         }
         $response = $client->request('GET', $this->mal_base_url . '' . $query);
         try {
             $xml = simplexml_load_string($response->html());
             return $xml;
         } catch (Exception $e) {
             $e->getMessage();
         }
     }
     return null;
 }
开发者ID:shaikhatik0786,项目名称:Masteranime,代码行数:19,代码来源:AnimeData.php

示例2: testUsesAuth

 public function testUsesAuth()
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $client->setAuth('me', '**');
     $crawler = $client->request('GET', 'http://www.example.com/');
     $request = $this->historyPlugin->getLastRequest();
     $this->assertEquals('me', $request->getUsername());
     $this->assertEquals('**', $request->getPassword());
 }
开发者ID:yanniboi,项目名称:github_drupalorg,代码行数:11,代码来源:ClientTest.php

示例3: testRestart

 public function testRestart()
 {
     $client = new Client();
     $client->setHeader('X-Test', 'test');
     $client->setAuth('foo', 'bar');
     $headersReflectionProperty = new \ReflectionProperty('Goutte\\Client', 'headers');
     $headersReflectionProperty->setAccessible(true);
     $this->assertEquals(array('X-Test' => 'test'), $headersReflectionProperty->getValue($client));
     $authReflectionProperty = new \ReflectionProperty('Goutte\\Client', 'auth');
     $authReflectionProperty->setAccessible(true);
     $this->assertEquals(array('foo', 'bar', 'basic'), $authReflectionProperty->getValue($client));
     $client->restart();
     $this->assertEquals([], $headersReflectionProperty->getValue($client));
     $this->assertNull($authReflectionProperty->getValue($client));
 }
开发者ID:fabpot,项目名称:goutte,代码行数:15,代码来源:ClientTest.php

示例4: testResetsAuth

 public function testResetsAuth()
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $client->setAuth('me', '**');
     $client->resetAuth();
     $crawler = $client->request('GET', 'http://www.example.com/');
     $request = $this->history->getLastRequest();
     $this->assertNull($request->getConfig()->get('auth')[0]);
     $this->assertNull($request->getConfig()->get('auth')[1]);
 }
开发者ID:b-sebastian,项目名称:timetable,代码行数:12,代码来源:ClientTest.php

示例5: testResetsAuth

 public function testResetsAuth()
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $client->setAuth('me', '**');
     $client->resetAuth();
     $client->request('GET', 'http://www.example.com/');
     $request = end($this->history)['request'];
     $this->assertEquals('', $request->getHeaderLine('authorization'));
 }
开发者ID:cclose,项目名称:Goutte,代码行数:11,代码来源:ClientTest.php


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