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


PHP Zend_Http_Client::setAuth方法代码示例

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


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

示例1: __construct

 public function __construct($apiKey, $subdomain, Zend_Http_Client $client)
 {
     $this->apiKey = $apiKey;
     $this->client = $client;
     $this->subdomain = $subdomain;
     $this->client->setAuth($this->apiKey, 'X');
 }
开发者ID:hhatfield,项目名称:hermes,代码行数:7,代码来源:Bot.php

示例2: __construct

 /**
  * Constructs a new Simpy (free) REST API Client
  *
  * @param  string $username Username for the Simpy user account
  * @param  string $password Password for the Simpy user account
  * @return void
  */
 public function __construct($username, $password)
 {
     /**
      * @see Zend_Service_Rest
      */
     require_once 'Zend/Rest/Client.php';
     $this->_http = new Zend_Http_Client();
     $this->_http->setAuth($username, $password);
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:16,代码来源:Simpy.php

示例3: __construct

 /**
  * the constructor
  *
  * don't use the constructor. use the singleton
  */
 private function __construct($_username, $_password, $_url)
 {
     $this->_url = empty($_url) ? 'https://samurai.sipgate.net/RPC2' : $_url;
     $this->_username = $_username;
     $this->_password = $_password;
     $this->_http = new Zend_Http_Client($this->_url);
     $this->_http->setMethod('post');
     $this->_http->setAuth($_username, $_password);
     $this->_rpc = new Zend_XmlRpc_Client($this->_url, $this->_http->setAuth($_username, $_password));
     $this->_rpc->call('samurai.ClientIdentify', array(0 => new Zend_XmlRpc_Value_Struct(array('ClientName' => new Zend_XmlRpc_Value_String('Tine 2.0 Sipgate'), 'ClientVersion' => new Zend_XmlRpc_Value_String('0.4'), 'ClientVendor' => new Zend_XmlRpc_Value_String('Alexander Stintzing')))));
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:16,代码来源:Api.php

示例4: request

 /**
  * Execute CheddarGetter API request
  *
  * @param string $url Url to the API action
  * @param string $username Username
  * @param string $password Password
  * @param array|null $args HTTP post key value pairs
  * @return string Body of the response from the CheddarGetter API
  * @throws Zend_Http_Client_Exception A Zend_Http_Client_Exception may
  * be thrown under a number of conditions but most likely if the tcp socket
  * fails to connect.
  */
 public function request($url, $username, $password, array $args = null)
 {
     // reset
     $this->_client->setUri($url);
     $this->_client->resetParameters();
     $this->_client->setMethod(Zend_Http_Client::GET);
     $this->_client->setAuth($username, $password);
     if ($args) {
         $this->_client->setMethod(Zend_Http_Client::POST);
         $this->_client->setParameterPost($args);
     }
     $response = $this->_client->request();
     return $response->getBody();
 }
开发者ID:robinsonryan,项目名称:cheddar-getter,代码行数:26,代码来源:ZendAdapter.php

示例5: _call

 protected function _call($endpoint, $params = null, $method = 'GET', $data = null)
 {
     if ($params && is_array($params) && count($params) > 0) {
         $args = array();
         foreach ($params as $arg => $val) {
             $args[] = urlencode($arg) . '=' . urlencode($val);
         }
         $endpoint .= '?' . implode('&', $args);
     }
     $url = $this->_getUrl($endpoint);
     $method = strtoupper($method);
     $client = new Zend_Http_Client($url);
     $client->setMethod($method);
     $client->setHeaders(array('Accept' => 'application/json', 'Content-Type' => 'application/json'));
     $client->setAuth(Mage::getStoreConfig('zendesk/general/email') . '/token', Mage::getStoreConfig('zendesk/general/password'));
     if ($method == 'POST') {
         $client->setRawData(json_encode($data), 'application/json');
     }
     Mage::log(print_r(array('url' => $url, 'method' => $method, 'data' => json_encode($data)), true), null, 'zendesk.log');
     $response = $client->request();
     $body = json_decode($response->getBody(), true);
     Mage::log(var_export($body, true), null, 'zendesk.log');
     if ($response->isError()) {
         if (is_array($body) && isset($body['error'])) {
             if (is_array($body['error']) && isset($body['error']['title'])) {
                 throw new Exception($body['error']['title'], $response->getStatus());
             } else {
                 throw new Exception($body['error'], $response->getStatus());
             }
         } else {
             throw new Exception($body, $response->getStatus());
         }
     }
     return $body;
 }
开发者ID:drunkvegas,项目名称:done,代码行数:35,代码来源:Abstract.php

示例6: icsAction

 public function icsAction()
 {
     $this->api_user = Mage::getModel('core/variable')->setStoreId(Mage::app()->getStore()->getId())->loadByCode('pmt_api_user')->getValue('text');
     $this->api_password = Mage::getModel('core/variable')->setStoreId(Mage::app()->getStore()->getId())->loadByCode('pmt_api_password')->getValue('text');
     // get prescription id
     $prescriptionRepeatId = Mage::app()->getRequest()->getParam('id');
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     $client = new Zend_Http_Client($this->api_get_prescripton_url . $prescriptionRepeatId);
     $params = ['pmt_user_id' => $customer->getId(), 'prescription_repeat_id' => $prescriptionRepeatId];
     // set some parameters
     $client->setParameterPost($params);
     $client->setAuth($this->api_user, $this->api_password, \Zend_Http_Client::AUTH_BASIC);
     // POST request
     $result = $client->request(Zend_Http_Client::POST);
     // decode response
     $jsonData = json_decode($result->getBody());
     //		var_dump($prescriptionRepeatId . $customer->getId());
     //		var_dump($result);
     //		exit();
     if (!$jsonData->status == 'success') {
         // create error message, before redirecting
         // redirect to prescriptions page
         $this->redirectDashboard();
     }
     $this->loadLayout();
     $block = $this->getLayout()->getBlock('prescriptions_ics');
     $block->assign(['repeat' => $jsonData->data->repeats[0], 'product' => $jsonData->data->prescription]);
     $this->renderLayout();
 }
开发者ID:technomagegithub,项目名称:inmed-magento,代码行数:29,代码来源:IndexController.php

示例7: mailgunRequest

 public function mailgunRequest($type, $domain, $apiKey, $data, $method = Zend_Http_Client::GET, $uriOveride = false)
 {
     $client = new Zend_Http_Client();
     $client->setAuth("api", $apiKey);
     $client->setMethod($method);
     if ($uriOveride) {
         $client->setUri($uriOveride);
     } else {
         $client->setUri($this->apiUrl . $domain . "/" . $type);
     }
     if ($method == Zend_Http_Client::POST) {
         foreach ($data as $key => $value) {
             $client->setParameterPost($key, $value);
         }
     } else {
         foreach ($data as $key => $value) {
             $client->setParameterGet($key, $value);
         }
     }
     try {
         $response = $client->request();
         if ($response->getStatus() == 200) {
             return json_decode($response->getBody());
         } else {
             throw new Zend_Http_Exception("Error connecting to MailGun API. Returned error code: " . $response->getStatus() . " --- " . $response->getBody());
         }
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
 }
开发者ID:reidblomquist,项目名称:mailgun_magento,代码行数:31,代码来源:Mailgun.php

示例8: testExceptUnsupportedAuthDynamic

    /**
     * Test setAuth (dynamic method) fails when trying to use an unsupported
     * authentication scheme
     *
     */
    public function testExceptUnsupportedAuthDynamic()
    {
        $this->setExpectedException(
            'Zend\Http\Client\Exception\InvalidArgumentException',
            'Invalid or not supported authentication type: \'SuperStrongAlgo\'');

        $this->_client->setAuth('shahar', '1234', 'SuperStrongAlgo');
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:13,代码来源:StaticTest.php

示例9: _post

 /**
  * Performs an HTTP POST request to $path.
  *
  * @param string $path
  * @param mixed $data Raw data to send
  * @throws Zend_Http_Client_Exception
  * @return Zend_Http_Response
  */
 protected function _post($path, $data = null)
 {
     $this->_prepare($path);
     if ($this->_authorizationCredentials) {
         $this->_localHttpClient->setAuth($this->getLogin() . "/token", $this->getToken());
     }
     return $this->_performPost('POST', $data);
 }
开发者ID:raphaelstolt,项目名称:github-api-client,代码行数:16,代码来源:GitHub.php

示例10: testExceptUnsupportedAuthDynamic

 /**
  * Test setAuth (dynamic method) fails when trying to use an unsupported
  * authentication scheme
  *
  */
 public function testExceptUnsupportedAuthDynamic()
 {
     try {
         $this->client->setAuth('shahar', '1234', 'SuperStrongAlgo');
         $this->fail('Trying to use unknown authentication method, setAuth should throw an exception but it didn\'t');
     } catch (Zend_Http_Client_Exception $e) {
         // We're good!
     }
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:14,代码来源:StaticTest.php

示例11: init

 /**
  * Initialize some of the basic properties.
  *
  * @return void
  */
 protected function init()
 {
     $config = Zend_Registry::getInstance()->config->watson;
     $client = new Zend_Http_Client();
     $client->setUri($config->baseUrl);
     $client->setAuth($config->username, $config->password, Zend_Http_Client::AUTH_BASIC);
     // Extra headers needed
     $client->setHeaders(array('X-SyncTimeout' => $config->timeout, 'Content-Type' => 'application/json', 'Accept' => 'application/json'));
     $this->_httpClient = $client;
 }
开发者ID:beesheer,项目名称:freehdfootage,代码行数:15,代码来源:Client.php

示例12: testCancelAuthWithCredentialsInUri

 /**
  * Test that we can unset HTTP authentication when credentials is specified in the URI
  *
  */
 public function testCancelAuthWithCredentialsInUri()
 {
     $uri = str_replace('http://', 'http://%s:%s@', $this->baseuri) . 'testHttpAuth.php';
     // Set auth and cancel it
     $this->client->setUri(sprintf($uri, 'alice', 'secret'));
     $this->client->setAuth(false);
     $res = $this->client->request();
     $this->assertEquals(401, $res->getStatus(), 'Expected HTTP 401 response was not recieved');
     $this->assertNotContains('alice', $res->getBody(), "Body contains the user name, but it shouldn't");
     $this->assertNotContains('secret', $res->getBody(), "Body contains the password, but it shouldn't");
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:15,代码来源:CommonHttpTests.php

示例13: testCancelAuth

 /**
  * Test we can unset HTTP authentication
  *
  */
 public function testCancelAuth()
 {
     $this->client->setUri($this->baseuri . 'testHttpAuth.php');
     // Set auth and cancel it
     $this->client->setAuth('alice', 'secret');
     $this->client->setAuth(false);
     $res = $this->client->request();
     $this->assertEquals(401, $res->getStatus(), 'Expected HTTP 401 response was not recieved');
     $this->assertNotContains('alice', $res->getBody(), "Body contains the user name, but it shouldn't");
     $this->assertNotContains('secret', $res->getBody(), "Body contains the password, but it shouldn't");
 }
开发者ID:lortnus,项目名称:zf1,代码行数:15,代码来源:SocketTest.php

示例14: sendCommand

 /**
  * send command
  *
  * @param string $_phoneAddress Address of the phone
  * @param array  $_params       command params
  */
 private function sendCommand($_phoneAddress, array $_params = array(), $_user = NULL, $_pass = NULL)
 {
     $_config = array('useragent' => 'PHP snom remote client (rev: 0.1)', 'keepalive' => false);
     $client = new Zend_Http_Client('http://' . $_phoneAddress . '/command.htm', $_config);
     $client->setAuth($_user, $_pass, Zend_Http_Client::AUTH_BASIC);
     $client->setParameterGet($_params);
     $response = $client->request('GET');
     if (!$response->isSuccessful()) {
         throw new Phone_Exception_Snom('HTTP request to ' . $_phoneAddress . ' failed');
     }
     return $response->getBody();
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:18,代码来源:Webserver.php

示例15: createFromConfigs

 public static function createFromConfigs(Zend_Config $config, $userId)
 {
     $httpClient = new Zend_Http_Client();
     $httpClient->setAuth($config->auth->user, $config->auth->password);
     $openSocialRestClient = new OpenSocial_Rest_Client($httpClient);
     $provider = new self($config->id, $config->name, $openSocialRestClient);
     $provider->configurePreconditions($config);
     $provider->configureGroupFilters($config);
     $provider->configureGroupMemberFilters($config);
     $decoratedProvider = $provider->configureDecoratorChain($config);
     return $decoratedProvider;
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:12,代码来源:HttpBasic.php


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