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


PHP http_parse_message函数代码示例

本文整理汇总了PHP中http_parse_message函数的典型用法代码示例。如果您正苦于以下问题:PHP http_parse_message函数的具体用法?PHP http_parse_message怎么用?PHP http_parse_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: execute

 /**
  * @param Request $wixHiveRequest
  *
  * @return Response
  * @throws WixHiveException
  */
 public function execute(Request $wixHiveRequest)
 {
     $resource = curl_init();
     curl_setopt($resource, CURLOPT_URL, $wixHiveRequest->endpoint);
     $this->setHttpMethod($resource, $wixHiveRequest);
     if ($this->isBodyRequired($wixHiveRequest->httpMethod)) {
         $this->setRequestBody($resource, $wixHiveRequest);
     }
     if (!empty($wixHiveRequest->headers)) {
         $headers = [];
         foreach ($wixHiveRequest->headers as $key => $value) {
             $headers[] = "{$key}: {$value}";
         }
         curl_setopt($resource, CURLOPT_HTTPHEADER, $headers);
     }
     curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($resource, CURLOPT_VERBOSE, 1);
     curl_setopt($resource, CURLOPT_HEADER, 1);
     $result = curl_exec($resource);
     curl_close($resource);
     //TODO process the case when there is no response from the service
     if (false === $result) {
     }
     $response = http_parse_message($result);
     $contentType = explode(";", $response->headers['Content-Type']);
     if (!isset($contentType[0]) || $contentType[0] !== "application/json") {
         throw new WixHiveException("Response content type is not supported", "415");
     }
     return new Response(json_decode($response->body));
 }
开发者ID:jonnywhite,项目名称:wixhive-php-api,代码行数:36,代码来源:Connector.php

示例2: request

    /**
     * try three different methods for http request,
     * @param type $url
     * @return type
     */
    function request($url){
        // use curl_get first if it is activated
        if(function_exists('curl_init')) {
            $this->opts = array(
                CURLOPT_HEADER => FALSE,
                CURLOPT_RETURNTRANSFER => TRUE
            );
            $result=$this->curl_get($url);
            return $result['cr'];
        // then try http_get
        }elseif(function_exists('http_get')){
            return http_parse_message(http_get($url))->body;

        // finally we have file_get_contents which is quite often deactivated
        }elseif(ini_get('allow_url_fopen')){
            return file_get_contents($url);
        }else{
            $this->error(__('Your server doesn\'t support remote exchanges.',WYSIJA));
            $this->error(__('Contact your administrator to modify that, it should be configurable.',WYSIJA));
            $this->error('<strong>CURL library</strong> DISABLED');
            $this->error('<strong>allow_url_fopen</strong> DISABLED');
            $this->error('<strong>PECL pecl_http >= 0.1.0</strong> DISABLED');
            return false;
        }
    }
开发者ID:pauEscarcia,项目名称:AIMM,代码行数:30,代码来源:HTTP.PHP

示例3: parseResponse

 public function parseResponse($message)
 {
     if (!$message) {
         return false;
     }
     $parts = http_parse_message($message);
     return array('protocol' => 'HTTP', 'version' => number_format($parts->httpVersion, 1), 'code' => $parts->responseCode, 'reason_phrase' => $parts->responseStatus, 'headers' => $parts->headers, 'body' => $parts->body);
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:8,代码来源:PeclHttpMessageParser.php

示例4: get_trusted_ticket

function get_trusted_ticket($wgserver, $user, $remote_addr)
{
    $params = array('username' => $user, 'client_ip' => $remote_addr);
    $server = PROTOCOL . "://{$wgserver}/trusted";
    $resp = http_parse_message(http_post_fields($server, $params))->body;
    //testing
    // print '<script type="text/javascript">alert("My addy ' . $_SERVER['SERVER_ADDR'] . ' is getting response from server ' . $server . ' for user ' . $user . ' of ' . print_r($resp) . '");</script>';
    //print_r ($resp);
    //actually return it
    return $resp;
}
开发者ID:rkulan007,项目名称:tableau-portal,代码行数:11,代码来源:tableau_trusted.php

示例5: fetchData

 protected function fetchData(Request $request)
 {
     $this->request = $request;
     include "getUA.php";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     $id = preg_replace("/.*?(\\d.*)/smi", "\\1", $request->getVehicleId());
     $this->scrapeURL .= "?l=" . $request->getLang() . "&s=1&tid=" . $id . "&da=D&p=2";
     $post = http_post_data($this->scrapeURL, "", $request_options) or die("");
     $body = http_parse_message($post)->body;
     return $body;
 }
开发者ID:janfabry,项目名称:iRail,代码行数:11,代码来源:BRailVehicleInput.php

示例6: httpcall

 private static function httpcall($url)
 {
     //maybe we should add the method to the config. Some servers have curl, some have this method:
     include "config.php";
     $request_options = array("referer" => "http://iRail.be/", "timeout" => "30", "useragent" => $iRailAgent);
     //echo $url;
     $post = http_post_data($url, "", $request_options) or die("");
     if ($post == "") {
         throw new Exception("Failed to contact the server");
     }
     return http_parse_message($post)->body;
 }
开发者ID:rubenslabbinck,项目名称:InfoScreen,代码行数:12,代码来源:APICall.class.php

示例7: getServerData

     private static function getServerData($id,$lang){
	  include_once("../includes/getUA.php");
	  $request_options = array(
	       "referer" => "http://api.irail.be/",
	       "timeout" => "30",
	       "useragent" => $irailAgent,
	       );
	  $scrapeURL = "http://www.railtime.be/mobile/HTML/TrainDetail.aspx";
	  $id = preg_replace("/.*?(\d.*)/smi", "\\1", $id);
	  $scrapeURL .= "?l=" . $lang . "&tid=" . $id . "&dt=" . date( 'd%2fm%2fY' );
	  $post = http_post_data($scrapeURL, "", $request_options) or die("");
	  return http_parse_message($post)->body;	  
     }
开发者ID:GMLudo,项目名称:iRail,代码行数:13,代码来源:vehicleinformation.php

示例8: _execute_query

 private function _execute_query($url)
 {
     $response = \http_get($url, array(), $response_info);
     if ($response_info['response_code'] != 200 || !$response) {
         return false;
     }
     $data = http_parse_message($response)->body;
     try {
         $data = json_decode($data, true);
     } catch (Exception $e) {
         return false;
     }
     return $data;
 }
开发者ID:3logic,项目名称:wpframework,代码行数:14,代码来源:NodeProxyProcess.php

示例9: http_parse_message

 function http_parse_message($res)
 {
     $this->response_raw = $res;
     $this->response_object = http_parse_message($res);
     if ($this->response_object->responseCode == 404) {
         throw new HttpServerException404($this->response_object->responseStatus);
     }
     if ($this->response_object->responseCode >= 400 && $this->response_object->responseCode <= 600) {
         throw new HttpServerException($this->response_object->responseStatus, $this->response_object->responseCode);
     }
     if (!in_array($this->response_object->responseCode, range(200, 207))) {
         throw new RestClientException($this->response_object->responseStatus, $this->response_object->responseCode);
     }
 }
开发者ID:rvyasg821,项目名称:rest-webservices,代码行数:14,代码来源:rest_client.php

示例10: internalCall

 /** Send a query using a specified request-method.
  *
  * @param	string	$query			Query to send. (Required)
  * @param	string	$requestMethod	Request-method for calling (defaults to 'GET'). (Optional)
  * @return	SimpleXMLElement		A SimpleXMLElement object.
  *
  * @access	protected
  * @internal
  */
 protected function internalCall($params, $requestMethod = 'GET')
 {
     /* Create caching hash. */
     $hash = Cache::createHash($params);
     /* Check if response is cached. */
     if ($this->cache != null && $this->cache->contains($hash) && !$this->cache->isExpired($hash)) {
         /* Get cached response. */
         $response = $this->cache->load($hash);
     } else {
         /* Build request query. */
         $query = http_build_str($params, '', '&');
         /* Set request options. */
         $options = array('useragent' => 'PHP last.fm API (PHP/' . phpversion() . ')');
         /* Clear response headers. */
         $this->headers = array();
         /* Get response */
         if ($requestMethod === 'POST') {
             $response = http_post_data(self::API_URL, $query, $options, $info);
         } else {
             $response = http_get(self::API_URL . '?' . $query, $options, $info);
         }
         $response = http_parse_message($response);
         foreach ($response->headers as $header => $value) {
             $this->headers[$header] = $value;
         }
         $response = $response->body;
         /* Cache it. */
         if ($this->cache != null) {
             if (array_key_exists('Expires', $this->headers)) {
                 $this->cache->store($hash, $response, strtotime($this->headers['Expires']));
             } else {
                 $expiration = $this->cache->getPolicy()->getExpirationTime($params);
                 if ($expiration > 0) {
                     $this->cache->store($hash, $response, time() + $expiration);
                 }
             }
         }
     }
     /* Create SimpleXMLElement from response. */
     $response = new SimpleXMLElement($response);
     /* Return response or throw an error. */
     if (Util::toString($response['status']) === 'ok') {
         if ($response->children()->{0}) {
             return $response->children()->{0};
         }
     } else {
         throw new Error(Util::toString($response->error), Util::toInteger($response->error['code']));
     }
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:58,代码来源:PeclCaller.php

示例11: fetchData

 private static function fetchData($station, $time, $lang, $timeSel)
 {
     include "../includes/getUA.php";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     $body = "";
     //we want data for 1 hour. But we can only retrieve 15 minutes per request
     for ($i = 0; $i < 4; $i++) {
         $scrapeUrl = "http://www.railtime.be/mobile/SearchStation.aspx";
         $scrapeUrl .= "?l=EN&tr=" . $time . "-15&s=1&sid=" . stations::getRTID($station, $lang) . "&da=" . $timeSel . "&p=2";
         $post = http_post_data($scrapeUrl, "", $request_options) or die("");
         $body .= http_parse_message($post)->body;
         $time = tools::addQuarter($time);
     }
     return $body;
 }
开发者ID:JeroenDeDauw,项目名称:iRail,代码行数:15,代码来源:liveboard.php

示例12: fetchData

 private static function fetchData($station, $time, $lang, $timeSel)
 {
     include "../includes/getUA.php";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     $body = "";
     //we want data for 1 hour. But we can only retrieve 15 minutes per request
     for ($i = 0; $i < 4; $i++) {
         $scrapeUrl = "http://www.railtime.be/mobile/HTML/StationDetail.aspx";
         $rt = stations::getRTID($station, $lang);
         $rtname = $rt->rtname;
         $rtid = $rt->rtid;
         $scrapeUrl .= "?sn=" . urlencode($rtname) . "&sid=" . urlencode($rtid) . "&ti=" . urlencode($time) . "&da=" . urlencode($timeSel) . "&l=EN&s=1";
         $post = http_post_data($scrapeUrl, "", $request_options) or die("");
         $body .= http_parse_message($post)->body;
         $time = tools::addQuarter($time);
     }
     return $body;
 }
开发者ID:GMLudo,项目名称:iRail,代码行数:18,代码来源:liveboard.php

示例13: get_dyn_pois

function get_dyn_pois($fw_dynamic)
{
    $conf_data = file_get_contents("poi_dp_dyn_conf.json");
    $conf = json_decode($conf_data, true);
    $sources = $fw_dynamic["sources"];
    $dyn_data = array();
    $n_sources = count($sources);
    for ($i = 0; $i < $n_sources; $i++) {
        $source = $sources[$i];
        $host = $source["host_type"];
        $type = $source["data_type"];
        if (array_key_exists('host_id', $source)) {
            $ids = $source["host_id"];
            $id = $source["host_id"][0];
        } else {
            $ids = array();
            $id = '';
        }
        switch ($conf["host_type"][$host]["method"]) {
            case "REST_GET":
                $url = $conf["host_type"][$host]["params"]["url"] . $id . $conf["host_type"][$host]["params"]["params"];
                $options = array('headers' => $conf["host_type"][$host]["params"]["headers"]);
                $output = http_get($url, $options);
                break;
            case "REST_POST":
                $i = 0;
                $data = $conf["host_type"][$host]["params"]["params"];
                foreach ($ids as $id) {
                    $data = str_replace('$' . $i++, $id, $data);
                }
                if (is_array($data)) {
                    $data = json_encode($data);
                }
                $output = http_post_data($conf["host_type"][$host]["params"]["url"], $data, array('headers' => $conf["host_type"][$host]["params"]["headers"]));
                break;
        }
        $data = http_parse_message($output)->body;
        // merge separate sources
        $mapped_data = map_data($conf["data_mapping"][$type], $data);
        $dyn_data = array_merge_r2($dyn_data, $mapped_data);
    }
    return $dyn_data;
}
开发者ID:Fiware,项目名称:webui.POIDataProvider,代码行数:43,代码来源:get_dyn_pois.php

示例14: request

 function request($url)
 {
     if (ini_get("allow_url_fopen")) {
         return file_get_contents($url);
     } elseif (function_exists('curl_init')) {
         $this->opts = array(CURLOPT_HEADER => FALSE, CURLOPT_RETURNTRANSFER => TRUE);
         $result = $this->curl_get($url);
         return $result['cr'];
     } elseif (function_exists('http_get')) {
         return http_parse_message(http_get($url))->body;
     } else {
         $this->error(__("Your server doesn't support remote exchanges.", WYSIJA));
         $this->error(__("Contact your administrator to modify that, it should be configurable.", WYSIJA));
         $this->error("<strong>CURL library</strong> DISABLED");
         $this->error("<strong>allow_url_fopen</strong> DISABLED");
         $this->error("<strong>PECL pecl_http >= 0.1.0</strong> DISABLED");
         return false;
     }
 }
开发者ID:rotoballer,项目名称:emily,代码行数:19,代码来源:http.php

示例15: fetchData

 protected function fetchData(Request $request)
 {
     include "getUA.php";
     $this->request = $request;
     $scrapeUrl = "http://www.railtime.be/mobile/SearchStation.aspx";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     $stationname = strtoupper($request->getStation());
     include "includes/railtimeids.php";
     if (array_key_exists($stationname, $railtimeids)) {
         $rtid = $railtimeids[$stationname];
     } else {
         throw new Exception("Station not available for liveboard", 3);
     }
     $this->arrdep = $request->getArrdep();
     $this->name = $request->getStation();
     $scrapeUrl .= "?l=" . $request->getLang() . "&s=1&sid=" . $rtid . "&da=" . substr($request->getArrdep(), 0, 1) . "&p=2";
     $post = http_post_data($scrapeUrl, "", $request_options) or die("");
     $body = http_parse_message($post)->body;
     return $body;
 }
开发者ID:janfabry,项目名称:iRail,代码行数:20,代码来源:BRailLiveboardInput.php


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