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


PHP Zend_Http_Client::setUri方法代码示例

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


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

示例1: 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

示例2: _request

 /**
  * 
  */
 protected function _request($url, $params, $method = Zend_Http_Client::GET)
 {
     $this->_client->setUri($url)->resetParameters();
     if (count($params['header'])) {
         foreach ($params['header'] as $name => $value) {
             $this->_client->setHeaders($name, $value);
         }
     }
     if (count($params['post'])) {
         foreach ($params['post'] as $name => $value) {
             $this->_client->setParameterPost($name, $value);
         }
     }
     if (count($params['get'])) {
         foreach ($params['get'] as $name => $value) {
             $this->_client->setParameterGet($name, $value);
         }
     }
     if (count($params['json'])) {
         //$this->_client->setHeaders('Content-type','application/json');
         $rawJson = json_encode($params['json']);
         //$this->_client->setRawData($rawJson);
         $this->_client->setRawData($rawJson, 'application/json');
     }
     $response = $this->_client->request($method);
     $result = $response->getBody();
     #echo $result . "\n\n <br>";
     return json_decode($result);
 }
开发者ID:rtsantos,项目名称:mais,代码行数:32,代码来源:Ice.php

示例3: _makeRequest

 /**
  * Sends a request to the REST API service and does initial processing
  * on the response.
  *
  * @param  string $op    Name of the operation for the request
  * @param  array  $query Query data for the request (optional)
  * @throws Zend_Service_Exception
  * @return DOMDocument Parsed XML response
  */
 protected function _makeRequest($op, $query = null)
 {
     if ($query != null) {
         $query = array_diff($query, array_filter($query, 'is_null'));
         $query = '?' . http_build_query($query);
     }
     $this->_http->setUri($this->_baseUri . $op . '.do' . $query);
     $response = $this->_http->request('GET');
     if ($response->isSuccessful()) {
         $doc = new DOMDocument();
         $doc->loadXML($response->getBody());
         $xpath = new DOMXPath($doc);
         $list = $xpath->query('/status/code');
         if ($list->length > 0) {
             $code = $list->item(0)->nodeValue;
             if ($code != 0) {
                 $list = $xpath->query('/status/message');
                 $message = $list->item(0)->nodeValue;
                 /**
                  * @see Zend_Service_Exception
                  */
                 require_once 'Zend/Service/Exception.php';
                 throw new Zend_Service_Exception($message, $code);
             }
         }
         return $doc;
     }
     /**
      * @see Zend_Service_Exception
      */
     require_once 'Zend/Service/Exception.php';
     throw new Zend_Service_Exception($response->getMessage(), $response->getStatus());
 }
开发者ID:basdog22,项目名称:Qool,代码行数:42,代码来源:Simpy.php

示例4: authenticate

 public function authenticate($user = null, $password = null)
 {
     $cfg = $this->config;
     $user = $user ? $user : $cfg->getUser();
     $password = $password ? $password : $cfg->getPassword();
     $url = 'http://' . $cfg->getHost() . ':' . $cfg->getPort() . '/_session';
     $response = $this->request->setUri($url)->resetParameters()->setHeaders('Content-Type', 'application/x-www-form-urlencoded')->setRawData("name={$user}&password={$password}")->request(\Zend_Http_Client::POST);
     return json_decode($response->getBody(), true);
 }
开发者ID:finalclass,项目名称:netcore,代码行数:9,代码来源:CouchDB.php

示例5: _getXml

 /**
  * Given a url, use the provider to pull from the url
  *
  * @param $url
  *
  * @return string
  */
 protected function _getXml($url)
 {
     if (is_null($this->_xmlProvider)) {
         $this->setXmlProvider(new Varien_Http_Adapter_Curl());
     }
     $this->_client->setUri($url ? $url : 'http');
     $response = $this->_client->request(Zend_Http_Client::GET);
     return $response->getBody();
 }
开发者ID:bevello,项目名称:bevello,代码行数:16,代码来源:Data.php

示例6: run

 public function run()
 {
     if ($this->debugMode) {
         echo "Restricting crawl to {$this->domain}\n";
     }
     //loop across available items in the queue of pages to crawl
     while (!$this->queue->isEmpty()) {
         if (isset($this->limit) && $this->counter >= $this->limit) {
             break;
         }
         $this->counter++;
         //get a new url to crawl
         $url = $this->queue->pop();
         if ($this->debugMode) {
             echo "Queue Length: " . $this->queue->queueLength() . "\n";
             echo "Crawling " . $url . "\n";
         }
         //set the url into the http client
         $this->client->setUri($url);
         //make the request to the remote server
         $this->currentResponse = $this->client->request();
         //don't bother trying to parse this if it's not text
         if (stripos($this->currentResponse->getHeader('Content-type'), 'text') === false) {
             continue;
         }
         //search for <a> tags in the document
         $body = $this->currentResponse->getBody();
         $linksQuery = new Zend_Dom_Query($body);
         $links = $linksQuery->query('a');
         if ($this->debugMode) {
             echo "\tFound " . count($links) . " links...\n";
         }
         foreach ($links as $link) {
             //get the href of the link and find out if it links to the current host
             $href = $link->getAttribute('href');
             $urlparts = parse_url($href);
             if ($this->stayOnDomain && isset($urlparts["host"]) && $urlparts["host"] != $this->domain) {
                 continue;
             }
             //if it's an absolute link without a domain or a scheme, attempt to fix it
             if (!isset($urlparts["host"])) {
                 $href = 'http://' . $this->domain . $href;
                 //this is a really naive way of doing this!
             }
             //push this link into the queue to be crawled
             $this->queue->push($href);
         }
         //for each page that we see, run every registered task across it
         foreach ($this->tasks as $task) {
             $task->task($this->currentResponse, $this->client);
         }
     }
     //after we're done with everything, call the shutdown hook on all the tasks
     $this->shutdownTasks();
 }
开发者ID:austinphp,项目名称:crawler,代码行数:55,代码来源:Crawler.php

示例7: sayRoom

 public function sayRoom($room, $message, $type = 'TextMessage')
 {
     $uri = 'https://' . $this->subdomain . '.campfirenow.com/room/' . $room . '/speak.json';
     $this->client->setUri($uri);
     $params['message']['type'] = $type;
     $params['message']['body'] = $message;
     $this->client->setHeaders('Content-type', 'application/json');
     $this->client->setRawData(json_encode($params));
     $this->client->setMethod(Zend_Http_Client::POST);
     $response = $this->client->request();
     return (bool) ($response->getStatus() == 200);
 }
开发者ID:hhatfield,项目名称:hermes,代码行数:12,代码来源:Bot.php

示例8: __construct

 /**
  * Enter description here...
  *
  * @param Zend_Service_PayPal_Data_AuthInfo $auth_info
  * @param Zend_Http_Client                  $httpClient
  */
 public function __construct(Zend_Service_PayPal_Data_AuthInfo $authInfo, $uri = self::SERVICE_URI, $httpClient = null)
 {
     $this->authInfo = $authInfo;
     if ($httpClient instanceof Zend_Http_Client) {
         $this->httpClient = $httpClient;
     } else {
         // Create and configure the default HTTP client
         $this->httpClient = new Zend_Http_Client();
         $this->httpClient->setConfig(array('adapter' => 'Zend_Http_Client_Adapter_Socket', 'maxredirects' => 0, 'timeout' => 60, 'ssltransport' => 'ssl'));
     }
     $this->httpClient->setUri($uri);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:PayPal.php

示例9: send

 /**
  * {@inheritdoc}
  */
 public function send($url, $payload)
 {
     try {
         $response = $this->client->setUri($url)->setHeaders($this->getHeaders())->setRawData($payload)->request('POST');
     } catch (HttpClientAdapterException $e) {
         throw TcpException::transportError($e);
     } catch (HttpClientException $e) {
         throw TcpException::transportError($e);
     }
     if ($response->getStatus() !== 200) {
         throw HttpException::httpError($response->getMessage(), $response->getStatus());
     }
     return $response->getBody();
 }
开发者ID:Banjerr,项目名称:infusionPress_Forms,代码行数:17,代码来源:ZendFrameworkOneHttpClientBridge.php

示例10: 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

示例11: execute

 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $supportSend = \SystemPref::get('support_send');
     if ($supportSend) {
         $stats = $this->getHelper('container')->getService('stat')->getAll();
         $statsUrl = 'http://stat.sourcefabric.org';
         $parameters = array('p' => 'newscoop');
         $parameters['installation_id'] = $stats['installationId'];
         $parameters['server'] = \SystemPref::get('support_stats_server');
         $parameters['ip_address'] = \SystemPref::get('support_stats_ip_address');
         $parameters['ram_used'] = $stats['ramUsed'];
         $parameters['ram_total'] = \SystemPref::get('support_stats_ram_total');
         $parameters['version'] = $stats['version'];
         $parameters['install_method'] = $stats['installMethod'];
         $parameters['publications'] = $stats['publications'];
         $parameters['issues'] = $stats['issues'];
         $parameters['sections'] = $stats['sections'];
         $parameters['articles'] = $stats['articles'];
         $parameters['articles_published'] = $stats['articlesPublished'];
         $parameters['languages'] = $stats['languages'];
         $parameters['authors'] = $stats['authors'];
         $parameters['subscribers'] = $stats['subscribers'];
         $parameters['backend_users'] = $stats['backendUsers'];
         $parameters['images'] = $stats['images'];
         $parameters['attachments'] = $stats['attachments'];
         $parameters['topics'] = $stats['topics'];
         $parameters['comments'] = $stats['comments'];
         $parameters['hits'] = $stats['hits'];
         $client = new \Zend_Http_Client();
         $client->setUri($statsUrl);
         $client->setParameterPost($parameters);
         $response = $client->request('POST');
     }
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:37,代码来源:SendStatsCommand.php

示例12: getNewSizingChartContent

 /**
  * Get Sizing Chart content from remote resource
  */
 public function getNewSizingChartContent($ptn)
 {
     if ($ptn) {
         $uri = Mage::getStoreConfig('yk_config/asc/url') . $ptn;
         $client = new Zend_Http_Client();
         $client->setUri($uri);
         $response = $client->request();
         if ($html = $response->getBody()) {
             $dom = new Zend_Dom_Query();
             $dom->setDocumentHtml($html);
             $results = $dom->query(Mage::getStoreConfig('yk_config/asc/container'));
             if (count($results)) {
                 foreach ($results as $result) {
                     $innerHTML = '';
                     $children = $result->childNodes;
                     foreach ($children as $child) {
                         $innerHTML .= $child->ownerDocument->saveHTML($child);
                     }
                     return $innerHTML;
                 }
             }
         }
     }
     return false;
 }
开发者ID:Vedariy,项目名称:test,代码行数:28,代码来源:Chart.php

示例13: urlAction

 /**
  * Action - url
  * check on the availability of URL
  *
  *
  * Access to the action is possible in the following paths:
  * - /utility/url
  *
  * @return void
  */
 public function urlAction()
 {
     // Получим обьект запроса
     $request = $this->getRequest();
     $params = $request->getParams();
     $type_action = $params['type_action'];
     if ($this->_isAjaxRequest) {
         $jsons = array();
         try {
             if ($type_action == 'check_exist') {
                 $url = $params['url'];
                 $client = new Zend_Http_Client();
                 $client->setUri($url);
                 $client->setConfig(array('maxredirects' => 0, 'timeout' => 5));
                 //Zend_Http_Request::
                 $response = $client->request();
                 //'CONNECT'
                 if ($response->isSuccessful()) {
                     $jsons['result'] = TRUE;
                 } else {
                     $jsons['result'] = FALSE;
                 }
             }
             $this->sendJson($jsons);
         } catch (Exception $exc) {
             $jsons['result'] = FALSE;
             $this->sendJson($jsons);
             return;
         }
     }
 }
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:41,代码来源:UtilityController.php

示例14: sendPOST

 /**
  * Send a POST request to the specified URL with the specified payload.
  * @param string $url
  * @param string $data
  * @return string Remote data
  **/
 public function sendPOST($url, $data = array())
 {
     $data['_fake_status'] = '200';
     // Zend makes it easier than the others...
     $this->instance->setConfig(array('useragent' => sprintf(Imgur::$user_agent, Imgur::$key)));
     $this->instance->setMethod(Zend_Http_Client::POST);
     $this->instance->setUri($url);
     $this->instance->setParameterPost($data);
     try {
         /** @var Zend_Http_Response */
         $response = $this->instance->request();
         return $response->getBody();
     } catch (Exception $e) {
         throw new Imgur_Exception("Unknown Failure during HTTP Request", null, $e);
     }
 }
开发者ID:plehnet,项目名称:Imgur-API-for-PHP,代码行数:22,代码来源:ZendHttpClient.php

示例15: execute

 protected function execute($arguments = array(), $options = array())
 {
     require_once realpath(dirname(__FILE__) . '/../../../../lib/vendor/OAuth/OAuth.php');
     new sfDatabaseManager($this->configuration);
     sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'), 'pc_frontend');
     $consumerKey = isset($options['consumer-key']) && $options['consumer-key'] ? $options['consumer-key'] : opOpenSocialToolKit::getOAuthConsumerKey();
     $consumer = new OAuthConsumer($consumerKey, null, null);
     $signatureMethod = new OAuthSignatureMethod_RSA_SHA1_opOpenSocialPlugin();
     $httpOptions = opOpenSocialToolKit::getHttpOptions();
     $queueGroups = Doctrine::getTable('ApplicationLifecycleEventQueue')->getQueueGroups();
     $limitRequest = (int) $options['limit-request'];
     $limitRequestApp = (int) $options['limit-request-app'];
     $allRequest = 0;
     foreach ($queueGroups as $group) {
         $application = Doctrine::getTable('Application')->find($group[0]);
         $links = $application->getLinks();
         $linkHash = array();
         foreach ($links as $link) {
             if (isset($link['rel']) && isset($link['href'])) {
                 $method = isset($link['method']) ? strtolower($link['method']) : '';
                 $method = 'post' !== $method ? 'get' : 'post';
                 $linkHash[$link['rel']] = array('href' => $link['href'], 'method' => $method);
             }
         }
         $queues = Doctrine::getTable('ApplicationLifecycleEventQueue')->getQueuesByApplicationId($group[0], $limitRequestApp);
         foreach ($queues as $queue) {
             if (!isset($linkHash[$queue->getName()])) {
                 $queue->delete();
                 continue;
             }
             $href = $linkHash[$queue->getName()]['href'];
             $method = $linkHash[$queue->getName()]['method'];
             $oauthRequest = OAuthRequest::from_consumer_and_token($consumer, null, $method, $href, $queue->getParams());
             $oauthRequest->sign_request($signatureMethod, $consumer, null);
             $client = new Zend_Http_Client();
             if ('post' !== $method) {
                 $method = 'get';
                 $client->setMethod(Zend_Http_Client::GET);
                 $href .= '?' . $oauthRequest->to_postdata();
             } else {
                 $client->setMethod(Zend_Http_Client::POST);
                 $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED);
                 $client->setRawData($oauthRequest->to_postdata());
             }
             $client->setConfig($httpOptions);
             $client->setUri($href);
             $client->setHeaders($oauthRequest->to_header());
             $response = $client->request();
             if ($response->isSuccessful()) {
                 $queue->delete();
             }
             $allRequest++;
             if ($limitRequest && $limitRequest <= $allRequest) {
                 break 2;
             }
         }
         $application->free(true);
         $queues->free(true);
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:60,代码来源:opOpenSocialExecuteLifecycleEventTask.class.php


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