本文整理汇总了PHP中http_parse_message函数的典型用法代码示例。如果您正苦于以下问题:PHP http_parse_message函数的具体用法?PHP http_parse_message怎么用?PHP http_parse_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了http_parse_message函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: facebookLogin
function facebookLogin($obj)
{
//Facebook Login start
if (isset($obj->io->input["get"]["code"])) {
$callback = isset($obj->io->input["get"]["redirect_param"]) ? 'redirect_param=' . $obj->io->input["get"]["redirect_param"] : "";
$param = http_build_query(array('client_id' => $obj->config->fb["appid"], "client_secret" => $obj->config->fb["secret"], 'redirect_uri' => $obj->openid->realm . '/' . $obj->io->input["get"]["fun"] . '/' . $obj->io->input["get"]["act"] . '/' . $callback, 'code' => $obj->io->input["get"]["code"], 'req_perms' => $obj->config->fb["req_perms"]));
$token = http_parse_message(http_get('https://graph.facebook.com/oauth/access_token?' . $param))->body;
if (is_object($error = json_decode($token))) {
echo "<pre>Facebook login error message\n";
echo $error->error->type . ":" . $error->error->message;
exit;
} else {
$info = json_decode(http_parse_message(http_get('https://graph.facebook.com/me?' . $token))->body);
$api_info = array();
$api_info["openid"] = $info->id;
$api_info["nickname"] = $info->name;
if (preg_match("/^([_.0-9a-z-]+)@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,4}\$/i", $info->email)) {
if ($obj->user->checkMemberId($info->email, $obj)) {
$api_info["memberid"] = '';
} else {
$api_info["memberid"] = $info->email;
}
$api_info["email"] = $info->email;
}
$api_info['birthday'] = date('Y-m-d', strtotime($info->birthday));
$api_info['sex'] = $info->gender == 'female' ? 'g' : 'b';
$user = array();
$user = $this->getOpenIdUser($info->id, 'facebook', $obj);
if (empty($user['openid'])) {
$this->registerOpenId($api_info, 'facebook', $obj);
$user = $this->getOpenIdUser($info->id, 'facebook', $obj);
}
return $this->openIdUserLogin($user, $obj);
}
//$obj->http->redirectUrl($obj);
}
//Facebook Login end
}
开发者ID:sjw-github,项目名称:lib,代码行数:38,代码来源:loginApi.ini.php
示例17: fetchData
/**
* This function will get the data from nmbs we need.
* @param Request $request
* @return <type>
*/
protected function fetchData(Request $request)
{
$this->request = $request;
include "getUA.php";
$url = "http://hari.b-rail.be/Hafas/bin/extxml.exe";
$request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
//first request: Getting the id of the right stations
$postdata = '<?xml version="1.0 encoding="iso-8859-1"?>
<ReqC ver="1.1" prod="iRail API v1.0" lang="EN">
<LocValReq id="from" maxNr="1">
<ReqLoc match="' . $request->getFrom() . '" type="ST"/>
</LocValReq>
<LocValReq id="to" maxNr="1">
<ReqLoc match="' . $request->getTo() . '" type="ST"/>
</LocValReq>
</ReqC>';
$post = http_post_data($url, $postdata, $request_options) or die("");
$idbody = http_parse_message($post)->body;
preg_match_all("/externalId=\"(.*?)\"/si", $idbody, $matches);
$idfrom = $matches[1][0];
$idto = $matches[1][1];
//for now
$trainsonly = "1111111111111111";
$timeSel = 0;
if ($request->getTimeSel() == "depart") {
$timeSel = 0;
} else {
if (strcmp($request->getTimeSel(), "arrive") == 0) {
$timeSel = 1;
}
}
//now we're going to get the real data
$postdata = '<?xml version="1.0 encoding="iso-8859-1"?>
<ReqC ver="1.1" prod="irail" lang="' . $request->getLang() . '">
<ConReq>
<Start min="0">
<Station externalId="' . $idfrom . '" distance="0">
</Station>
<Prod prod="' . $trainsonly . '">
</Prod>
</Start>
<Dest min="0">
<Station externalId="' . $idto . '" distance="0">
</Station>
</Dest>
<Via>
</Via>
<ReqT time="' . $request->getTime() . '" date="' . $request->getDate() . '" a="' . $timeSel . '">
</ReqT>
<RFlags b="' . $request->getResults() * $timeSel . '" f="' . $request->getResults() * -($timeSel - 1) . '">
</RFlags>
<GISParameters>
<Front>
</Front>
<Back>
</Back>
</GISParameters>
</ConReq>
</ReqC>';
$post = http_post_data($url, $postdata, $request_options) or die("<br />NMBS/SNCB website timeout. Please <a href='..'>refresh</a>.");
return http_parse_message($post)->body;
}
开发者ID:janfabry,项目名称:iRail,代码行数:67,代码来源:BRailConnectionInput.php
示例18: FetchHTTP
function FetchHTTP($url, $inHeaders = array(), &$outHeaders = array())
{
static $isRetry = false;
global $fetchHTTPErrorCaught;
$wasRetry = $isRetry;
$isRetry = false;
$fetchHTTPErrorCaught = false;
if (!isset($inHeaders['Connection'])) {
$inHeaders['Connection'] = 'Keep-Alive';
}
$inHeaders['Accept-Encoding'] = 'gzip';
$http_opt = array('timeout' => 60, 'connecttimeout' => 6, 'headers' => $inHeaders, 'compress' => true, 'redirect' => 3);
//if ($eTag) $http_opt['etag'] = $eTag;
$http_info = array();
$fetchHTTPErrorCaught = false;
$oldErrorReporting = error_reporting(error_reporting() | E_WARNING);
set_error_handler('FetchHTTPError', E_WARNING);
$data = http_parse_message(http_get($url, $http_opt, $http_info));
restore_error_handler();
error_reporting($oldErrorReporting);
unset($oldErrorReporting);
if (!$data) {
$outHeaders = array();
return false;
}
$outHeaders = array_merge(array('httpVersion' => $data->httpVersion, 'responseCode' => $data->responseCode, 'responseStatus' => $data->responseStatus), $data->headers);
//if (isset($data->headers['Etag']))
// $eTag = $data->headers['Etag'];
if ($fetchHTTPErrorCaught) {
return false;
}
if (preg_match('/^2\\d\\d$/', $http_info['response_code']) > 0) {
return $data->body;
} elseif (!$wasRetry && isset($data->headers['Retry-After'])) {
$delay = intval($data->headers['Retry-After'], 10);
DebugMessage("Asked to wait {$delay} seconds for {$url}", E_USER_NOTICE);
if ($delay > 0 && $delay <= 10) {
sleep($delay);
}
$isRetry = true;
return FetchHTTP($url, $inHeaders, $outHeaders);
} else {
return false;
}
}
开发者ID:erorus,项目名称:realmpop,代码行数:45,代码来源:incl.php
示例19: post
public function post($url, $data = array())
{
$response = http_post($url, $data);
$parsed = http_parse_message($response);
return $parsed;
}
开发者ID:benjaminhawkeslewis,项目名称:SevenLeggedSpider,代码行数:6,代码来源:SevenLeggedSpider.php
示例20: getRawData
public function getRawData($argsi, $type = 'product')
{
$url = $this->getUrl($argsi, $type);
$body = http_parse_message(http_get($url));
return $body->body;
}
开发者ID:sjw-github,项目名称:lib,代码行数:6,代码来源:GrouponAPI.ini.php
注:本文中的http_parse_message函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论