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


PHP HTTP_Request2::send方法代码示例

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


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

示例1: erzData

 public function erzData($zip = null, $type = null, $page = 1)
 {
     if ($type) {
         $url = 'http://openerz.herokuapp.com:80/api/calendar/' . $type . '.json';
     } else {
         $url = 'http://openerz.herokuapp.com:80/api/calendar.json';
     }
     //Http-request
     $request = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
     $reqUrl = $request->getUrl();
     $pageSize = 10;
     $reqUrl->setQueryVariable('limit', $pageSize);
     $offset = ($page - 1) * $pageSize;
     $reqUrl->setQueryVariable('offset', $offset);
     if ($zip) {
         $reqUrl->setQueryVariable('zip', $zip);
     }
     try {
         $response = $request->send();
         // 200 ist für den Status ob ok ist 404 wäre zum Beispiel ein Fehler
         if ($response->getStatus() == 200) {
             return json_decode($response->getBody());
         }
     } catch (HTTP_Request2_Exception $ex) {
         echo $ex;
     }
     return null;
 }
开发者ID:Nithuja,项目名称:ERZ,代码行数:28,代码来源:index.php

示例2: testDefaultPrivacyEdit

 /**
  * Test that the default privacy setting is used when an existing
  * bookmark is updated with edit.php.
  */
 public function testDefaultPrivacyEdit()
 {
     $this->setUnittestConfig(array('defaults' => array('privacy' => 2)));
     list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1');
     $cookies = $req->getCookieJar();
     $req->setMethod(HTTP_Request2::METHOD_POST);
     $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_edit');
     $req->addPostParameter('description', 'Test bookmark 2 for default privacy.');
     $req->addPostParameter('status', '0');
     $res = $req->send();
     $this->assertEquals(200, $res->getStatus(), 'Adding bookmark failed: ' . $res->getBody());
     $bms = $this->bs->getBookmarks(0, null, $uId);
     $bm = reset($bms['bookmarks']);
     $bmId = $bm['bId'];
     $reqUrl = $GLOBALS['unittestUrl'] . 'edit.php/' . $bmId . '?unittestMode=1';
     $req2 = new HTTP_Request2($reqUrl, HTTP_Request2::METHOD_POST);
     $req2->setCookieJar($cookies);
     $req2->addPostParameter('address', 'http://www.example.org/testdefaultprivacyposts_edit');
     $req2->addPostParameter('title', 'Test bookmark 2 for default privacy.');
     $req2->addPostParameter('submitted', '1');
     $res = $req2->send();
     $this->assertEquals(302, $res->getStatus(), 'Editing bookmark failed');
     $bm = $this->bs->getBookmark($bmId);
     $this->assertEquals('2', $bm['bStatus']);
 }
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:29,代码来源:editTest.php

示例3: get_request

    /**
     * GET Request
     *
     * @param $url
     * @param $datas
     * @return string
     */
    public function get_request($url, $datas = array())
    {
        $body = '';
        try {
            $url2 = new Net_URL2($url);
            foreach ($datas as $key => $val) {
                $url2->setQueryVariable($key, mb_convert_encoding($val, $this->response_encoding, 'UTF-8'), true);
            }

            $this->http->setURL($url2);
            $this->http->setMethod(HTTP_Request2::METHOD_GET);
            if (!empty($this->cookies)) {
                foreach ($this->cookies as $cookie) {
                    $this->http->addCookie($cookie['name'], $cookie['value']);
                }
            }

            $response = $this->http->send();

            if (count($response->getCookies())) {
                $this->cookies = $response->getCookies();
            }

            $body = mb_convert_encoding($response->getBody(), 'UTF-8', $this->response_encoding);

        } catch (Exception $e) {
            debug($e->getMessage());
        }

        return $body;
    }
开发者ID:nojimage,项目名称:twitter2mixivoice,代码行数:38,代码来源:Client.php

示例4: request

 private function request($method, $path, $params = array())
 {
     $url = $this->api . rtrim($path, '/') . '/';
     if (!strcmp($method, "POST")) {
         $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST);
         $req->setHeader('Content-type: application/json');
         if ($params) {
             $req->setBody(json_encode($params));
         }
     } else {
         if (!strcmp($method, "GET")) {
             $req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
             $url = $req->getUrl();
             $url->setQueryVariables($params);
         } else {
             if (!strcmp($method, "DELETE")) {
                 $req = new HTTP_Request2($url, HTTP_Request2::METHOD_DELETE);
                 $url = $req->getUrl();
                 $url->setQueryVariables($params);
             }
         }
     }
     $req->setAdapter('curl');
     $req->setConfig(array('timeout' => 30));
     $req->setAuth($this->auth_id, $this->auth_token, HTTP_Request2::AUTH_BASIC);
     $req->setHeader(array('Connection' => 'close', 'User-Agent' => 'PHPPlivo'));
     $r = $req->send();
     $status = $r->getStatus();
     $body = $r->getbody();
     $response = json_decode($body, true);
     return array("status" => $status, "response" => $response);
 }
开发者ID:davidangelcb,项目名称:voice,代码行数:32,代码来源:plivo.php

示例5: __construct

 private function __construct()
 {
     // sanity check
     $siteUrl = get_option('siteurl');
     $layoutUrl = DAIQUIRI_URL . '/core/layout/';
     if (strpos($layoutUrl, $siteUrl) !== false) {
         echo '<h1>Error with theme</h1><p>Layout URL is below CMS URL.</p>';
         die(0);
     }
     // construct request
     require_once 'HTTP/Request2.php';
     $req = new HTTP_Request2($layoutUrl);
     $req->setConfig(array('ssl_verify_peer' => false, 'connect_timeout' => 2, 'timeout' => 3));
     $req->setMethod('GET');
     $req->addCookie("PHPSESSID", $_COOKIE["PHPSESSID"]);
     try {
         $response = $req->send();
         if (200 != $response->getStatus()) {
             echo '<h1>Error with theme</h1><p>HTTP request status != 200.</p>';
             die(0);
         }
     } catch (HTTP_Request2_Exception $e) {
         echo '<h1>Error with theme</h1><p>Error with HTTP request.</p>';
         die(0);
     }
     $body = explode('<!-- content -->', $response->getBody());
     if (count($body) == 2) {
         $this->_header = $body[0];
         $this->_footer = $body[1];
     } else {
         echo '<h1>Error with theme</h1><p>Malformatted layout.</p>';
         die(0);
     }
 }
开发者ID:vrtulka23,项目名称:daiquiri,代码行数:34,代码来源:functions.php

示例6: send_post_data

function send_post_data($url, $data)
{
    require_once 'HTTP/Request2.php';
    $request = new HTTP_Request2($url);
    $request->setMethod(HTTP_Request2::METHOD_POST)->addPostParameter($data);
    return $request->send();
}
开发者ID:jabouzi,项目名称:belron,代码行数:7,代码来源:functions_helper.php

示例7: getRss

function getRss($url, $port, $timeout)
{
    $results = array('rss' => array(), 'error' => "");
    try {
        $request = new HTTP_Request2($url, HTTP_Request2::METHOD_POST);
        $request->setConfig("connect_timeout", $timeout);
        $request->setConfig("timeout", $timeout);
        $request->setHeader("user-agent", $_SERVER['HTTP_USER_AGENT']);
        $response = $request->send();
        if ($response->getStatus() == 200) {
            // パース
            $body = $response->getBody();
            if (substr($body, 0, 5) == "<?xml") {
                $results['rss'] = new MagpieRSS($body, "UTF-8");
            } else {
                throw new Exception("Not xml data");
            }
        } else {
            throw new Exception("Server returned status: " . $response->getStatus());
        }
    } catch (HTTP_Request2_Exception $e) {
        $results['error'] = $e->getMessage();
    } catch (Exception $e) {
        $results['error'] = $e->getMessage();
    }
    // タイムアウト戻し
    ini_set('default_socket_timeout', $oldtimeout);
    return $results;
}
开发者ID:homework-bazaar,项目名称:zencart-sugu,代码行数:29,代码来源:functions.php

示例8: send

 /**
  * Processes the reuqest through HTTP pipeline with passed $filters, 
  * sends HTTP request to the wire and process the response in the HTTP pipeline.
  * 
  * @param array $filters HTTP filters which will be applied to the request before
  *                       send and then applied to the response.
  * @param IUrl  $url     Request url.
  * 
  * @throws WindowsAzure\Common\ServiceException
  * 
  * @return string The response body
  */
 public function send($filters, $url = null)
 {
     if (isset($url)) {
         $this->setUrl($url);
         $this->_request->setUrl($this->_requestUrl->getUrl());
     }
     $contentLength = Resources::EMPTY_STRING;
     if (strtoupper($this->getMethod()) != Resources::HTTP_GET && strtoupper($this->getMethod()) != Resources::HTTP_DELETE && strtoupper($this->getMethod()) != Resources::HTTP_HEAD) {
         $contentLength = 0;
         if (!is_null($this->getBody())) {
             $contentLength = strlen($this->getBody());
         }
         $this->_request->setHeader(Resources::CONTENT_LENGTH, $contentLength);
     }
     foreach ($filters as $filter) {
         $this->_request = $filter->handleRequest($this)->_request;
     }
     $this->_response = $this->_request->send();
     $start = count($filters) - 1;
     for ($index = $start; $index >= 0; --$index) {
         $this->_response = $filters[$index]->handleResponse($this, $this->_response);
     }
     self::throwIfError($this->_response->getStatus(), $this->_response->getReasonPhrase(), $this->_response->getBody(), $this->_expectedStatusCodes);
     return $this->_response->getBody();
 }
开发者ID:southworkscom,项目名称:azure-sdk-for-php,代码行数:37,代码来源:HttpClient.php

示例9: fetchLunchMenus

 /**
  * さくら水産のランチ情報を取得する
  *
  * @return array | false
  */
 public function fetchLunchMenus()
 {
     $menus = array();
     $today = new DateTime();
     $request = new HTTP_Request2();
     $request->setMethod(HTTP_Request2::METHOD_GET);
     $request->setUrl(self::LUNCHMENU_URL);
     try {
         $response = $request->send();
         if (200 == $response->getStatus()) {
             $dom = new DOMDocument();
             @$dom->loadHTML($response->getBody());
             $xml = simplexml_import_dom($dom);
             foreach ($xml->xpath('//table/tr') as $tr) {
                 if (preg_match('/(\\d+)月(\\d+)日/', $tr->td[0]->div, $matches)) {
                     $dateinfo = new DateTime(sprintf('%04d-%02d-%02d', $today->format('Y'), $matches[1], $matches[2]));
                     $_menus = array();
                     foreach ($tr->td[1]->div->strong as $strong) {
                         $_menus[] = (string) $strong;
                     }
                     $menus[$dateinfo->format('Y-m-d')] = $_menus;
                 }
             }
         }
     } catch (HTTP_Request2_Exception $e) {
         // HTTP Error
         return false;
     }
     return $menus;
 }
开发者ID:riaf,项目名称:Wozozo_Sakusui,代码行数:35,代码来源:Sakusui.php

示例10: getLanguagesFromTransifex

 public function getLanguagesFromTransifex()
 {
     $request = new HTTP_Request2('http://vela1606:pass@www.transifex.net/api/2/project/gaiaehr/resource/All/?details', HTTP_Request2::METHOD_GET);
     $r = $request->send()->getBody();
     $r = json_decode($r, true);
     return array('langs' => $r['available_languages']);
 }
开发者ID:nhom5UET,项目名称:tichhophethong,代码行数:7,代码来源:Languages.php

示例11: main

 /**
  * Make the GET request
  *
  * @throws BuildException
  */
 public function main()
 {
     if (!isset($this->url)) {
         throw new BuildException("Missing attribute 'url'");
     }
     if (!isset($this->dir)) {
         throw new BuildException("Missing attribute 'dir'");
     }
     $this->log("Fetching " . $this->url);
     $request = new HTTP_Request2($this->url);
     $response = $request->send();
     if ($response->getStatus() != 200) {
         throw new BuildException("Request unsuccessfull. Response from server: " . $response->getStatus() . " " . $response->getReasonPhrase());
     }
     $content = $response->getBody();
     if ($this->filename) {
         $filename = $this->filename;
     } elseif ($disposition = $response->getHeader('content-disposition') && 0 == strpos($disposition, 'attachment') && preg_match('/filename="([^"]+)"/', $disposition, $m)) {
         $filename = basename($m[1]);
     } else {
         $filename = basename(parse_url($this->url, PHP_URL_PATH));
     }
     if (!is_writable($this->dir)) {
         throw new BuildException("Cannot write to directory: " . $this->dir);
     }
     $filename = $this->dir . "/" . $filename;
     file_put_contents($filename, $content);
     $this->log("Contents from " . $this->url . " saved to {$filename}");
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:34,代码来源:HttpGetTask.php

示例12: sendRequest

 /**
  * Sends the request via HTTP_Request2
  * 
  * @return string The HTTP response body
  */
 protected function sendRequest()
 {
     $this->getHTTPRequest2();
     $this->response = $this->request->send();
     if ($this->response->getStatus() !== 200) {
         throw new OpenID_Discover_Exception('Unable to connect to OpenID Provider.');
     }
     return $this->response->getBody();
 }
开发者ID:shupp,项目名称:openid,代码行数:14,代码来源:HTML.php

示例13: sendRequest

 /**
  * Sends a request and returns a response
  *
  * @param CartRecover_Request $request
  * @return Cart_Recover_Response
  */
 public function sendRequest(CartRecover_Request $request)
 {
     $this->client->setUrl($request->getUri());
     $this->client->getUrl()->setQueryVariables($request->getParams());
     $this->client->setMethod($request->getMethod());
     $this->client->setHeader('Accept', 'application/json');
     $this->response = $this->client->send();
     if ($this->response->getHeader('Content-Type') != 'application/json') {
         throw new CartRecover_Exception_UnexpectedValueException("Unknown response format.");
     }
     $body = json_decode($this->response->getBody(), true);
     $response = new CartRecover_Response();
     $response->setRawResponse($this->response->getBody());
     $response->setBody($body);
     $response->setHeaders($this->response->getHeader());
     $response->setStatus($this->response->getReasonPhrase(), $this->response->getStatus());
     return $response;
 }
开发者ID:digital-canvas,项目名称:cart-recover-phpapi,代码行数:24,代码来源:PEAR.php

示例14: request

 /**
  * Http request
  *
  * @param string $method
  * @param string $url
  * @param array  $submit
  * @param string $formName
  *
  * @return HTTP_Request2_Response
  */
 public function request($method, $url, array $submit = array(), $formName = 'form')
 {
     $this->request = new HTTP_Request2();
     $url = new Net_URL2($url);
     $this->request->setMethod($method);
     if ($submit) {
         $submit = array_merge(array('_token' => '0dc59902014b6', '_qf__' . $formName => ''), $submit);
     }
     if ($submit && $method === 'POST') {
         $this->request->addPostParameter($submit);
     }
     if ($submit && $method === 'GET') {
         $url->setQueryVariables($submit);
     }
     $this->request->setUrl($url);
     $this->response = $this->request->send();
     return $this;
 }
开发者ID:ryo88c,项目名称:BEAR.Saturday,代码行数:28,代码来源:Client.php

示例15: testRedirectsNonHTTP

 public function testRedirectsNonHTTP()
 {
     $this->request->setUrl($this->baseUrl . 'redirects.php?special=ftp')->setConfig(array('follow_redirects' => true));
     try {
         $this->request->send();
         $this->fail('Expected HTTP_Request2_Exception was not thrown');
     } catch (HTTP_Request2_Exception $e) {
     }
 }
开发者ID:rogerwu99,项目名称:punch_bantana,代码行数:9,代码来源:CommonNetworkTest.php


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