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


PHP HTTP_Request::setMethod方法代码示例

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


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

示例1: SendTrackback

 /**
  * Send a trackback to a site
  *
  * @access  public
  * @param   string  $title     Title of the Site
  * @param   string  $excerpt   The Excerpt
  * @param   string  $permalink The Permalink to send
  * @param   array   $to        Where to send the trackback
  */
 function SendTrackback($title, $excerpt, $permalink, $to)
 {
     $title = urlencode(stripslashes($title));
     $excerpt = urlencode(stripslashes($excerpt));
     $blog_name = urlencode(stripslashes($this->gadget->registry->fetch('site_name', 'Settings')));
     $permalink = urlencode($permalink);
     require_once PEAR_PATH . 'HTTP/Request.php';
     $options = array();
     $timeout = (int) $this->gadget->registry->fetch('connection_timeout', 'Settings');
     $options['timeout'] = $timeout;
     if ($this->gadget->registry->fetch('proxy_enabled', 'Settings') == 'true') {
         if ($this->gadget->registry->fetch('proxy_auth', 'Settings') == 'true') {
             $options['proxy_user'] = $this->gadget->registry->fetch('proxy_user', 'Settings');
             $options['proxy_pass'] = $this->gadget->registry->fetch('proxy_pass', 'Settings');
         }
         $options['proxy_host'] = $this->gadget->registry->fetch('proxy_host', 'Settings');
         $options['proxy_port'] = $this->gadget->registry->fetch('proxy_port', 'Settings');
     }
     $httpRequest = new HTTP_Request('', $options);
     $httpRequest->setMethod(HTTP_REQUEST_METHOD_POST);
     foreach ($to as $url) {
         $httpRequest->setURL($url);
         $httpRequest->addPostData('title', $title);
         $httpRequest->addPostData('url', $permalink);
         $httpRequest->addPostData('blog_name', $blog_name);
         $httpRequest->addPostData('excerpt', $excerpt);
         $resRequest = $httpRequest->sendRequest();
         $httpRequest->clearPostData();
     }
 }
开发者ID:juniortux,项目名称:jaws,代码行数:39,代码来源:Trackbacks.php

示例2: exportarDados

 /**
  * Método que encapsula a chamada do WEB SERVICE que traduz um arquivo .HTML em outras extensões.
  * Utilizado para exportar dados para arquivos a desejo do usuário.
  * 
  * @param texto $arquivoFetch nome do arquivo a ser utilizado para exportação, desde a pasta 'html'.
  * @param texto $extensaoDestino mine type para arquivo exportado.
  * @param texto $nomeArquivo nome a ser exibido no download do arquivo.
  */
 function exportarDados($arquivoFetch, $nomeArquivo = "Relatório.pdf", $extensaoDestino = "application/pdf", $fazerDownload = true)
 {
     $codigoHtml = $this->smarty->fetch($arquivoFetch);
     $codigoHtml = str_replace("html/css/", URL_COMPLETA . "html/css/", $codigoHtml);
     $codigoHtml = str_replace("html/img/", URL_COMPLETA . "html/img/", $codigoHtml);
     $request = new HTTP_Request(WEBSERVICE_BROFFICE_URL);
     $request->setMethod("POST");
     $request->addHeader("Content-Type", "text/html");
     $request->addHeader("Accept", $extensaoDestino);
     $request->setBody($codigoHtml);
     $request->sendRequest();
     $status = $request->getResponseCode();
     //echo $request->getResponseBody(); die;
     if ($status != 200) {
         echo "Ocorreu um erro na conversão. Favor entrar em contato com o administrador.";
         die;
     }
     if ($fazerDownload) {
         header("Content-Type: " . $extensaoDestino . "\n");
         header("Content-Disposition: attachment; filename=" . $nomeArquivo);
         echo $request->getResponseBody();
         die;
     }
     return $request->getResponseBody();
 }
开发者ID:ViniciusFelix,项目名称:ProjetoPadrao,代码行数:33,代码来源:negocio.php

示例3: fetchData

 function fetchData($username, $password)
 {
     switch ($this->options['cryptType']) {
         case 'blowfish':
             include_once 'Crypt/Blowfish.php';
             $bf = new Crypt_Blowfish($this->options['cryptKey']);
             $password = $bf->encrypt($password);
             $password = base64_encode($password);
             break;
         default:
             if (function_exists($this->options['cryptType'])) {
                 $password = $this->options['cryptType']($password);
             }
             break;
     }
     $req = new HTTP_Request();
     $req->setURL($this->options['URL']);
     $req->setMethod(HTTP_REQUEST_METHOD_GET);
     $req->addQueryString($this->options['usernameKey'], $username);
     $req->addQueryString($this->options['passwordKey'], $password);
     if (!PEAR::isError($req->sendRequest())) {
         $response = $req->getResponseBody();
     } else {
         return false;
     }
     $unserializer = new XML_Unserializer();
     if ($unserializer->unserialize($response)) {
         $this->result_value = $unserializer->getUnserializedData();
         if ($this->result_value[$this->options['resultKey']] == $this->options['correctValue']) {
             return true;
         }
     }
     return false;
 }
开发者ID:KimuraYoichi,项目名称:PukiWiki,代码行数:34,代码来源:REST_XML.php

示例4: getRequest

 /**
  * @brief HTTP request 객체 생성
  **/
 function getRequest($url)
 {
     $oReqeust = new HTTP_Request($url);
     $oReqeust->addHeader('Content-Type', 'application/xml');
     $oReqeust->setMethod('GET');
     return $oReqeust;
 }
开发者ID:hottaro,项目名称:xpressengine,代码行数:10,代码来源:lifepod.model.php

示例5: setInputFile

 /**
  * Sets the input xml file to be parsed
  *
  * @access  public
  * @param   string  $file  Filename(full path)
  * @return  mixed   True on success or error on failure
  */
 function setInputFile($file)
 {
     require_once PEAR_PATH . 'HTTP/Request.php';
     $httpRequest = new HTTP_Request($file, $this->_params);
     $httpRequest->setMethod(HTTP_REQUEST_METHOD_GET);
     $resRequest = $httpRequest->sendRequest();
     if (PEAR::isError($resRequest)) {
         return $resRequest;
     } elseif ($httpRequest->getResponseCode() != 200) {
         return $this->raiseError('HTTP response error', HTTP_REQUEST_ERROR_RESPONSE);
     }
     $data = trim($httpRequest->getResponseBody());
     if (version_compare(PHP_VERSION, '5.0.0', '<')) {
         if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $data, $matches)) {
             $srcenc = strtoupper($matches[1]);
             if (!in_array($srcenc, $this->_validEncodings)) {
                 if (function_exists('iconv')) {
                     $data = @iconv($srcenc, 'UTF-8', $data);
                 } elseif (function_exists('mb_list_encodings') && in_array($srcenc, array_map('strtoupper', mb_list_encodings()))) {
                     $data = @mb_convert_encoding($data, 'UTF-8', $srcenc);
                 }
             }
         }
     }
     $this->setInputString($data);
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:34,代码来源:XML_Feed.php

示例6: save

 function save($data)
 {
     if (!$data['GA_optin']) {
         trigger_error('did not opt to join');
         return true;
     }
     $options = $this->getOptions();
     $request = new HTTP_Request($options['hostname'] . '/offsite-join.tcl');
     $request->setMethod(HTTP_REQUEST_METHOD_POST);
     $request->addPostData('domain', $options['domain']);
     if ($options['source']) {
         $request->addPostData('source', $options['source']);
     }
     if ($options['update']) {
         $request->addPostData('update', $options['update']);
     }
     foreach ($this->translate($data) as $name => $value) {
         $request->addPostData($name, $value);
     }
     if (!PEAR::isError($request->sendRequest())) {
         $message = trim($request->getResponseBody());
         if ('OK' == $message) {
             return true;
         } else {
             $this->ERROR = $message;
             trigger_error($message);
             return false;
         }
     }
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:30,代码来源:Save.inc.php

示例7: _fetch

 /**
  * Helper function to fetch HTTP-URLs
  *
  * @param string $url
  * @return string
  * @todo Error handling is missing
  */
 protected function _fetch($url)
 {
     require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
     $request = new HTTP_Request($url);
     $request->setMethod(HTTP_REQUEST_METHOD_GET);
     $request->sendRequest();
     return $request->getResponseBody();
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:15,代码来源:abstract.php

示例8: getRequest

 /**
  * @brief HTTP request 객체 생성
  **/
 function getRequest($url)
 {
     $oReqeust = new HTTP_Request($url);
     $oReqeust->addHeader('Content-Type', 'application/xml');
     $oReqeust->setMethod('GET');
     $oReqeust->setBasicAuth($this->getUserID(), $this->getPassword());
     return $oReqeust;
 }
开发者ID:hottaro,项目名称:xpressengine,代码行数:11,代码来源:springnote.model.php

示例9: post

 /**
  * 投稿実行
  */
 public function post()
 {
     $hr = new HTTP_Request($this->getPostUrl());
     $hr->addHeader('X-WSSE', $this->wsse);
     $hr->addHeader('Accept', 'application/x.atom+xml, application/xml, text/xml, */*');
     $hr->addHeader('Authorization', 'WSSE profile="UsernameToken"');
     $hr->addHeader('Content-Type', 'application/x.atom+xml');
     $hr->addRawPostData($this->getRawdata());
     $hr->setMethod(HTTP_REQUEST_METHOD_POST);
     $hr->sendRequest();
     $hr->clearPostData();
 }
开发者ID:youg0717,项目名称:ameblo,代码行数:15,代码来源:Ameblo.php

示例10: getURL

 /**
  *
  */
 function getURL($url)
 {
     require_once PEAR_PATH . 'HTTP/Request.php';
     $httpRequest = new HTTP_Request($url);
     $httpRequest->setMethod(HTTP_REQUEST_METHOD_GET);
     $resRequest = $httpRequest->sendRequest();
     if (!PEAR::isError($resRequest) && $httpRequest->getResponseCode() == 200) {
         $data = $httpRequest->getResponseBody();
     } else {
         $data = @file_get_contents($url);
     }
     return $data;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:16,代码来源:AddressProtector.php

示例11: doHeadRequest

/**
* Send an HTTP HEAD request for the given URL
*
* @param    string  $url        URL to request
* @param    string  &$errmsg    error message, if any (on return)
* @return   int                 HTTP response code or 777 on error
*
*/
function doHeadRequest($url, &$errmsg)
{
    require_once 'HTTP/Request.php';
    $req = new HTTP_Request($url);
    $req->setMethod(HTTP_REQUEST_METHOD_HEAD);
    $req->addHeader('User-Agent', 'Geeklog/' . VERSION);
    $response = $req->sendRequest();
    if (PEAR::isError($response)) {
        $errmsg = $response->getMessage();
        return 777;
    } else {
        return $req->getResponseCode();
    }
}
开发者ID:hostellerie,项目名称:nexpro,代码行数:22,代码来源:sectest.php

示例12: getRequestInstance

 function getRequestInstance($url, $http_verb = 'GET', $options = array(), $body = '')
 {
     $default_options = array('header' => array(), 'params' => array());
     $options = array_merge($default_options, $options);
     $options['header']['user-agent'] = empty($options['header']['user-agent']) ? 'Akelos PHP Framework AkHttpClient (http://akelos.org)' : $options['header']['user-agent'];
     list($user_name, $password) = $this->_extractUserNameAndPasswordFromUrl($url);
     require_once AK_VENDOR_DIR . DS . 'pear' . DS . 'HTTP' . DS . 'Request.php';
     $this->{'_setParamsFor' . ucfirst(strtolower($http_verb))}($url, $options['params']);
     $this->HttpRequest =& new HTTP_Request($url);
     $user_name ? $this->HttpRequest->setBasicAuth($user_name, $password) : null;
     $this->HttpRequest->setMethod(constant('HTTP_REQUEST_METHOD_' . $http_verb));
     if ($http_verb == 'PUT' && !empty($options['params'])) {
         $this->setBody(http_build_query($options['params']));
     }
     if (!empty($body)) {
         $this->setBody($body);
     }
     if (!empty($options['file'])) {
         $this->HttpRequest->addFile($options['file']['inputname'], $options['file']['filename']);
     }
     !empty($options['params']) && $this->addParams($options['params']);
     $this->addHeaders($options['header']);
     return $this->HttpRequest;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:24,代码来源:AkHttpClient.php

示例13: sendNotification

function sendNotification($message, $regId)
{
    $apikey = "AIzaSyDh3_C0r5OxdGGHN516XleJ1G_-aAMxEC4";
    $rq = new HTTP_Request("https://android.googleapis.com/gcm/send");
    $rq->setMethod(HTTP_REQUEST_METHOD_POST);
    $rq->addHeader("Authorization", "key=" . $apikey);
    $rq->addPostData("registration_id", $regId);
    $rq->addPostData("collapse_key", "1");
    $rq->addPostData("data.message", $message);
    if (!PEAR::isError($rq->sendRequest())) {
        print "\n" . $rq->getResponseBody();
    } else {
        print "\nError has occurred";
    }
}
开发者ID:enpitut,项目名称:glasses,代码行数:15,代码来源:sendNotification.php

示例14: post

 /**
  * Posts data to the URL
  *
  * @access  public
  * @param   string  $url        URL address
  * @param   array   $params     Associated name/data values
  * @param   string  $response   Response body
  * @return  mixed   Response code on success, otherwise Jaws_Error
  */
 function post($url, $params = array(), &$response)
 {
     $httpRequest = new HTTP_Request($url, $this->options);
     $httpRequest->addHeader('User-Agent', $this->user_agent);
     $httpRequest->setMethod(HTTP_REQUEST_METHOD_POST);
     // add post data
     foreach ($params as $key => $data) {
         $httpRequest->addPostData($key, urlencode($data));
     }
     $result = $httpRequest->sendRequest();
     if (PEAR::isError($result)) {
         return Jaws_Error::raiseError($result->getMessage(), $result->getCode(), $this->default_error_level, 1);
     }
     $response = $httpRequest->getResponseBody();
     return $httpRequest->getResponseCode();
 }
开发者ID:juniortux,项目名称:jaws,代码行数:25,代码来源:HTTPRequest.php

示例15: process

 function process($table, $data)
 {
     $req = new HTTP_Request($this->api_url);
     $req->setMethod(HTTP_REQUEST_METHOD_GET);
     foreach ($data as $key => $val) {
         $req->addQueryString($key, $val);
     }
     $req->addQueryString('org', trim($this->org_id));
     $req->addQueryString('table', $table);
     if (!PEAR::isError($req->sendRequest())) {
         $out = $req->getResponseBody();
     } else {
         $out = null;
     }
     return $out;
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:16,代码来源:diaRequest.inc.php


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