當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。