本文整理汇总了PHP中http_post_data函数的典型用法代码示例。如果您正苦于以下问题:PHP http_post_data函数的具体用法?PHP http_post_data怎么用?PHP http_post_data使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了http_post_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSocial
public function actionSocial()
{
$req = Yii::$app->request;
$i = $req->get('i');
$c = $req->get('c');
$a = $req->get('a');
//se inicia sesion en el ampache
$Conexion = BaseJson::decode($this->actionConnectionParams());
$datos = "";
$peticionAmpache = http_post_data($Conexion["url"] . 'action=' . $Conexion['action'] . "&auth=" . $Conexion['auth'] . "×tamp=" . $Conexion['timestamp'] . "&version=" . $Conexion['version'] . "&user=" . $Conexion['user'], $datos, array("timeout" => 1, "useragent" => ""));
$peticionAmpache = substr($peticionAmpache, strpos($peticionAmpache, '<'));
$peticionAmpache = substr($peticionAmpache, 0, -5);
//return $peticionAmpache;
$xml = simplexml_load_string($peticionAmpache);
$token = $xml->auth;
//se pide la informacion del album
$peticionAmpache = http_post_data($Conexion["url"] . "auth=" . $token . "&action=album_songs&filter=" . $a, $datos);
//return $peticionAmpache;
$peticionAmpache = substr(substr($peticionAmpache, strpos($peticionAmpache, '<')), 0, -5);
$xml = simplexml_load_string($peticionAmpache);
//"renderizamos la vista"
$salida = $this->render('index', ['urlimg' => $xml->song[0]->art, 'descripcion' => 'Escuchando ' . $xml->song[0]->album . ' en Radio Album!']);
//le agregamos los parametros necesarios
$salida .= '<div id="parametros" data-skin="' . $i . 'vplayer" data-album="' . $a . '" data-channel="' . $c . '"></div>' . $peticionAmpache;
//mostramos la vista
return $salida;
}
示例2: find
public function find($email)
{
$data = array('EMAIL' => rawurldecode($email));
$return_content = http_post_data("http://itandroidbalance.miyigame.com/getbaseurl2.php", json_encode(array('email' => $email, 'platform' => 'xiaomi')));
$return = json_decode($return_content, true);
$baseurl = $return["baseurl"];
$db_group_var = "db1";
if ($baseurl == "itofdp4.miyigame.com:40002") {
$db_group_var = "db1";
} elseif ($baseurl == "itofdp5.miyigame.com:40003") {
$db_group_var = "db2";
} elseif ($baseurl == "itofdp6.miyigame.com:40004") {
$db_group_var = "db3";
}
$this->session->set_tempdata('db_group', $db_group_var, 600);
$this->load->model(array('User_data', 'Character_data', 'Skill_data', 'Treasure_data', 'Game_data', 'Item_data', 'Shop_data', 'Message_data'));
$userRows = $this->User_data->selectUser($data);
if (count($userRows) == 0) {
js_alert_back('Empty no data.');
} else {
if (count($userRows) == 1) {
js_redirect(site_url(array('user', 'view', $userRows[0]['USER_ID'])));
} else {
$data['USER_ROWS'] = $userRows;
$this->viewer->all('user/find', $data);
}
}
}
示例3: post
function post($url, $fields = array(), $http_options = array())
{
$http_options = array_merge($this->http_options, $http_options);
$res = is_array($fields) ? http_post_fields($url, $fields, array(), $http_options, $this->response_info) : http_post_data($url, $fields, $http_options, $this->response_info);
$this->http_parse_message($res);
return $this->response_object->body;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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']));
}
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: refreshSession
/**
* Refreshes a user's session.
*
* @return true if refreshSession is successful
*/
protected function refreshSession()
{
global $databaseURI;
$_SESSION['SESSION'] = $this->hashData("md5", session_id() . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']);
// create Session in DB
$sessionbody = array('user' => $_SESSION['UID'], 'session' => $_SESSION['SESSION']);
$sessionbody = json_encode($sessionbody);
$url = "{$databaseURI}/session";
http_post_data($url, $sessionbody, false, $message);
// only true if session is created in DB
if ($message == "201") {
$_SESSION['SIGNED'] = true;
$_SESSION['LASTACTIVE'] = $_SERVER['REQUEST_TIME'];
$_SESSION['HTTP_USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
$_SESSION['IP'] = $_SERVER['REMOTE_ADDR'];
return true;
} else {
return false;
}
}
示例12: 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;
}
示例13: FormEvaluator
$f = new FormEvaluator($_POST);
$f->checkStringForKey('userName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidUserName', $langTemplate), array('min' => 1));
$f->checkIntegerForKey('rights', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidCourseStatus', $langTemplate), array('min' => 0, 'max' => 2));
if ($f->evaluate(true)) {
$foundValues = $f->foundValues;
$userName = $foundValues['userName'];
$rights = $foundValues['rights'];
$URL = $databaseURI . '/user/user/' . $userName;
$user = http_get($URL, true);
$user = json_decode($user, true);
if (isset($user['id'])) {
$userId = $user['id'];
$newUser = User::createCourseStatus($userId, $cid, $rights);
$newUser = User::encodeUser($newUser);
$URL = $databaseURI . '/coursestatus';
http_post_data($URL, $newUser, true, $message);
if ($message == "201") {
$addUserNotifications[] = MakeNotification('success', Language::Get('main', 'successAddUser', $langTemplate));
} else {
$addUserNotifications[] = MakeNotification('error', Language::Get('main', 'errorAddUser', $langTemplate));
}
} else {
$addUserNotifications[] = MakeNotification('error', Language::Get('main', 'invalidUserId', $langTemplate));
}
} else {
if (!isset($addUserNotifications)) {
$addUserNotifications = array();
}
$addUserNotifications = $addUserNotifications + $f->notifications;
}
} else {
示例14: getStationFromName
public static function getStationFromName($name, $lang)
{
//We can do a couple of things here:
// * Match the name with something in the DB
// * Give the name to hafas so that it returns us an ID which we can reuse - Doesn't work for external stations
// * Do a hybrid mode
// * match from location
// * match railtime name
//Let's go wih the hafas solution and get the location from it
//fallback for wrong hafas information
if (strtolower($name) == "brussels north" || strtolower($name) == "brussel noord" || strtolower($name) == "bruxelles nord") {
return stations::getStationFromLocation(4.360854, 50.859658, $lang);
}
if (strtolower($name) == "vorst zuid") {
return stations::getStationFromLocation(4.310025, 50.810158, $lang);
}
include "../includes/getUA.php";
$url = "http://hari.b-rail.be/Hafas/bin/extxml.exe";
$request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
$postdata = '<?xml version="1.0 encoding="iso-8859-1"?>
<ReqC ver="1.1" prod="iRail API v1.0" lang="' . $lang . '">
<LocValReq id="stat1" maxNr="1">
<ReqLoc match="' . $name . '" type="ST"/>
</LocValReq>
</ReqC>';
$post = http_post_data($url, $postdata, $request_options) or die("");
$idbody = http_parse_message($post)->body;
preg_match("/x=\"(.*?)\".*?y=\"(.*?)\"/si", $idbody, $matches);
$x = $matches[1];
$y = $matches[2];
preg_match("/(.)(.*)/", $x, $m);
$x = $m[1] . "." . $m[2];
preg_match("/(..)(.*)/", $y, $m);
$y = $m[1] . "." . $m[2];
return stations::getStationFromLocation($x, $y, $lang);
}
示例15: http_parse_message
//echo $url . "<br>";
//echo $data . "<br>";
//echo $request_options . "<br>";
$body = http_parse_message($post)->body;
//This code fixes most hated issue #2 →→ You can buy me a beer in Ghent at anytime if you leave me a message at +32484155429
$dummy = preg_match("/(query\\.exe\\/..\\?seqnr=1&ident=.*?).OK.focus\" id=\"formular\"/si", $body, $matches);
if ($matches[1] != "") {
//DEBUG:echo $matches[1];
//scrape the date & time layout from $body
preg_match("/value=\"(.., ..\\/..\\/..)\" onblur=\"checkWeekday/si", $body, $datelay);
$datelay[1] = urlencode($datelay[1]);
preg_match("/name=\"REQ0JourneyTime\" value=\"(..:..)\"/si", $body, $timelay);
$timelay[1] = urlencode($timelay[1]);
$passthrough_url = "http://hari.b-rail.be/HAFAS/bin/" . $matches[1] . "&queryPageDisplayed=yes&REQ0JourneyStopsS0A=1%26fromTypeStation%3Dhidden&REQ0JourneyStopsS0K=S-0N1&REQ0JourneyStopsZ0A=1%26toTypeStation%3Dhidden&REQ0JourneyStopsZ0K=S-1N1&REQ0JourneyDate=" . $datelay[1] . "&wDayExt0=Ma|Di|Wo|Do|Vr|Za|Zo&REQ0JourneyTime=" . $timelay[1] . "&REQ0HafasSearchForw=1&REQ0JourneyProduct_prod_list=" . $trainsonly . "&start=Submit";
//DEBUG:echo "\n". $passthrough_url;
$post = http_post_data($passthrough_url, null, $request_options);
$body = http_parse_message($post)->body;
}
// check if nmbs planner is down
if (strstr($body, "[Serverconnection]") && strstr($body, "[Server]")) {
$down = 1;
} else {
$down = 0;
}
$body = strstr($body, '<table CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="100%" BGCOLOR="#FFFFFF">');
if ($body == "" && $down == 0) {
header('Location: noresults');
} else {
$body = str_replace('<table CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="100%" BGCOLOR="#FFFFFF">', '<table CELLSPACING="0" CELLPADDING="0" BORDER="0" BGCOLOR="#FFFFFF">', $body);
$body = str_replace("<img ", "<img border=\"0\" ", $body);
$body = str_replace("<td ", "<td NOWRAP ", $body);