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