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


PHP Zend_Http_Client::setMethod方法代码示例

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


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

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

示例2: fetchRequest

 public function fetchRequest(RemoteContentRequest $request)
 {
     $outHeaders = array();
     if ($request->hasHeaders()) {
         $headers = explode("\n", $request->getHeaders());
         foreach ($headers as $header) {
             if (strpos($header, ':')) {
                 $key = trim(substr($header, 0, strpos($header, ':')));
                 $val = trim(substr($header, strpos($header, ':') + 1));
                 if (strcmp($key, "User-Agent") != 0 && strcasecmp($key, "Transfer-Encoding") != 0 && strcasecmp($key, "Cache-Control") != 0 && strcasecmp($key, "Expries") != 0 && strcasecmp($key, "Content-Length") != 0) {
                     $outHeaders[$key] = $val;
                 }
             }
         }
     }
     $outHeaders['User-Agent'] = "Shindig PHP";
     $options = array();
     $options['timeout'] = Shindig_Config::get('curl_connection_timeout');
     // configure proxy
     $proxyUrl = Shindig_Config::get('proxy');
     if (!empty($proxyUrl)) {
         $options['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
         $proxy = parse_url($proxyUrl);
         if (isset($proxy['host'])) {
             $options['proxy_host'] = $proxy['host'];
         }
         if (isset($proxy['port'])) {
             $options['proxy_port'] = $proxy['port'];
         }
         if (isset($proxy['user'])) {
             $options['proxy_user'] = $proxy['user'];
         }
         if (isset($proxy['pass'])) {
             $options['proxy_pass'] = $proxy['pass'];
         }
     }
     $client = new Zend_Http_Client();
     $client->setConfig($options);
     $client->setUri($request->getUrl());
     $client->setHeaders($outHeaders);
     if ($request->getContentType()) {
         $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, $request->getContentType());
     }
     if ($request->isPost()) {
         $client->setMethod(Zend_Http_Client::POST);
         $client->setRawData($request->getPostBody());
     } else {
         $client->setMethod(Zend_Http_Client::GET);
     }
     $response = $client->request();
     $request->setHttpCode($response->getStatus());
     $request->setContentType($response->getHeader('Content-Type'));
     $request->setResponseHeaders($response->getHeaders());
     $request->setResponseContent($response->getBody());
     $request->setResponseSize(strlen($response->getBody()));
     return $request;
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:57,代码来源:opShindigRemoteContentFetcher.class.php

示例3: getHttpClient

 /**
  * Returns http client object
  *
  * @return \Zend_Http_Client
  */
 public function getHttpClient()
 {
     if (null === $this->_client) {
         $this->_client = new \Zend_Http_Client();
         $headers = array('Accept' => 'application/json', 'X-Postmark-Server-Token' => $this->_apiKey);
         $this->_client->setMethod(\Zend_Http_Client::GET)->setHeaders($headers);
     }
     return $this->_client;
 }
开发者ID:sumoheavy,项目名称:magento2-postmark,代码行数:14,代码来源:Postmark.php

示例4: __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

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

示例6: dispatch

 /**
  * Proxy, der zB für cross-domain ajax requests verwendet werden kann
  *
  * @param string|array $hosts Erlaubte Hostnamen (RegExp erlaubt, ^ vorne und $ hinten werden autom. angefügt)
  */
 public static function dispatch($hostnames)
 {
     if (Kwf_Setup::getRequestPath() === false) {
         return;
     }
     if (!preg_match('#^/kwf/proxy/?$#i', Kwf_Setup::getRequestPath())) {
         return;
     }
     if (is_string($hostnames)) {
         $hostnames = array($hostnames);
     }
     $proxyUrl = $_REQUEST['proxyUrl'];
     $proxyPostVars = $_POST;
     $proxyGetVars = $_GET;
     if (array_key_exists('proxyUrl', $proxyPostVars)) {
         unset($proxyPostVars['proxyUrl']);
     }
     if (array_key_exists('proxyUrl', $proxyGetVars)) {
         unset($proxyGetVars['proxyUrl']);
     }
     // host checking
     $proxyHost = parse_url($proxyUrl, PHP_URL_HOST);
     $matched = false;
     foreach ($hostnames as $hostname) {
         if (preg_match('/^' . $hostname . '$/i', $proxyHost)) {
             $matched = true;
             break;
         }
     }
     if (!$matched) {
         return;
     }
     // proxying
     $http = new Zend_Http_Client($proxyUrl);
     if (count($_POST)) {
         $http->setMethod(Zend_Http_Client::POST);
     } else {
         $http->setMethod(Zend_Http_Client::GET);
     }
     if (count($_GET)) {
         $http->setParameterGet($proxyGetVars);
     }
     if (count($_POST)) {
         $http->setParameterPost($proxyPostVars);
     }
     $response = $http->request();
     $headers = $response->getHeaders();
     if ($headers && !empty($headers['Content-type'])) {
         header("Content-Type: " . $headers['Content-type']);
     }
     echo $response->getBody();
     exit;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:58,代码来源:SimpleHttpProxy.php

示例7: getClient

 /**
  * @return Zend_Http_Client
  *
  * @throws Zend_Http_Client_Exception
  */
 public function getClient()
 {
     if (!$this->_client) {
         $secretKey = $this->_helper()->getConfigSecretApiKey();
         $this->_client = new Zend_Http_Client();
         $this->_client->setHeaders('clickpag-access-token', $secretKey);
         $this->_client->setHeaders('clickpag-api-version', 'v1');
         $this->_client->setHeaders('Content-Type', 'application/json');
         $this->_client->setHeaders('Accept', 'application/json');
         $this->_client->setMethod(Zend_Http_Client::POST);
     }
     return $this->_client;
 }
开发者ID:marcoescudeiro,项目名称:clickpag-magento,代码行数:18,代码来源:Api.php

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

示例9: process

 /**
  * 
  * @throws Exception
  * @return Varien_Object
  */
 public function process()
 {
     $cacheId = $this->_getCacheKey();
     $response = $cacheId ? Mage::app()->loadCache($cacheId) : false;
     if ($response) {
         $response = unserialize($response);
     }
     if (!$response instanceof Varien_Object) {
         $client = new Zend_Http_Client(self::API_URI, $this->_clientConfig);
         $client->setMethod(Zend_Http_Client::POST);
         $client->setParameterPost($this->getParams());
         $result = $client->request();
         $data = Zend_Json::decode($result->getBody());
         if ($data['status'] != 201) {
             throw new Exception("Premailer failed to run: {$data['message']} #{$data['status']}");
         }
         $htmlClient = new Zend_Http_Client($data['documents']['html'], $this->_clientConfig);
         $textClient = new Zend_Http_Client($data['documents']['txt'], $this->_clientConfig);
         $response = new Varien_Object();
         $response->setVersion($data['version']);
         $response->setHtml($htmlClient->request()->getBody());
         $response->setText($textClient->request()->getBody());
         if ($cacheId) {
             $data = Mage::app()->saveCache(serialize($response), $cacheId, array(self::CACHE_KEY), 60 * 60);
         }
     }
     return $response;
 }
开发者ID:jsiefer,项目名称:emarketing,代码行数:33,代码来源:Premailer.php

示例10: executeRequest

 public function executeRequest(TingClientHttpRequest $request)
 {
     //Transfer request configuration to Zend Client
     $method = $request->getMethod();
     $class = new ReflectionClass(get_class($this->client));
     $this->client->setMethod($class->getConstant($method));
     $this->client->setUri($request->getBaseUrl());
     $this->client->setParameterGet($request->getParameters(TingClientHttpRequest::GET));
     $this->client->setParameterPost($request->getParameters(TingClientHttpRequest::POST));
     //Check for errors
     $response = $this->client->request();
     if ($response->isError()) {
         throw new TingClientException('Unable to excecute Zend Framework HTTP request: ' . $response->getMessage(), $response->getStatus());
     }
     return $response->getBody();
 }
开发者ID:reload,项目名称:ting-client,代码行数:16,代码来源:TingClientZfHttpRequestAdapter.php

示例11: login

 static function login($request)
 {
     $forumPath = SJB_Settings::getSettingByName('forum_path');
     if (empty($forumPath)) {
         return;
     }
     $username = $request['username'];
     $password = $request['password'];
     $url = SJB_System::getSystemSettings('SITE_URL') . $forumPath . '/ucp.php?mode=login';
     $client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent()));
     $client->setCookie($_COOKIE);
     $client->setMethod(Zend_Http_Client::POST);
     $client->setParameterPost(array('username' => $username, 'password' => $password, 'login' => 'Login', 'autologin' => '', 'viewonline' => ''));
     $client->setCookieJar();
     try {
         $ret = $client->request();
         foreach ($ret->getHeaders() as $key => $header) {
             if ('set-cookie' == strtolower($key)) {
                 if (is_array($header)) {
                     foreach ($header as $val) {
                         header("Set-Cookie: " . $val, false);
                     }
                 } else {
                     header("Set-Cookie: " . $header, false);
                 }
             }
         }
     } catch (Exception $ex) {
     }
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:30,代码来源:phpbb_bridge_plugin.php

示例12: _httpRequest

 /**
  * Performs HTTP request to given $url using given HTTP $method.
  * Send additinal query specified by variable/value array,
  * On success returns HTTP response without headers, false on failure.
  *
  * @param string $url OpenID server url
  * @param string $method HTTP request method 'GET' or 'POST'
  * @param array $params additional qwery parameters to be passed with
  * @param int &$staus HTTP status code
  *  request
  * @return mixed
  */
 protected function _httpRequest($url, $method = 'GET', array $params = array(), &$status = null)
 {
     $client = $this->_httpClient;
     if ($client === null) {
         $client = new Zend_Http_Client($url, array('maxredirects' => 4, 'timeout' => 15, 'useragent' => 'Zend_OpenId'));
     } else {
         $client->setUri($url);
     }
     $client->resetParameters();
     if ($method == 'POST') {
         $client->setMethod(Zend_Http_Client::POST);
         $client->setParameterPost($params);
     } else {
         $client->setMethod(Zend_Http_Client::GET);
         $client->setParameterGet($params);
     }
     try {
         $response = $client->request();
     } catch (Exception $e) {
         $this->_setError('HTTP Request failed: ' . $e->getMessage());
         return false;
     }
     $status = $response->getStatus();
     $body = $response->getBody();
     if ($status == 200 || $status == 400 && !empty($body)) {
         return $body;
     } else {
         $this->_setError('Bad HTTP response');
         return false;
     }
 }
开发者ID:highfidelity,项目名称:love,代码行数:43,代码来源:Consumer.php

示例13: _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

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

示例15: getResponse

 public function getResponse()
 {
     $client = new Zend_Http_Client($this->_uri);
     $client->setMethod(Zend_Http_Client::POST);
     $client->setParameterPost(array('apiKey' => $this->getApiKey(), 'token' => $this->getToken()));
     return $client->request();
 }
开发者ID:revoleers,项目名称:rewardimizer-server,代码行数:7,代码来源:AuthInfo.php


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