本文整理汇总了PHP中httpPost函数的典型用法代码示例。如果您正苦于以下问题:PHP httpPost函数的具体用法?PHP httpPost怎么用?PHP httpPost使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了httpPost函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ip_wpcf7_mail_sent
function ip_wpcf7_mail_sent($wpcf7){
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$formdata = $submission->get_posted_data();
$email = $formdata['your-email'];
$first_name = $formdata['your-first-name'];
$last_name = $formdata['your-last-name'];
$tel = $formdata['your-tel'];
$plan = $formdata['your-plan'];
}
$time = $today = date("F j, Y, g:i a");
// Open Agent:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://ag.panda8.co/api?action=createAgentPph&creditAgent=1000&credit=100¤cy=USD&masterId=DEMVI&numOfUser=1&email='.$email.'&key=BBBAB3NzaC1yc2EAAAABJQAAAIEAhCdDMhGHdaw1uj9MH2xCB4jktwIgm4Al7S8rxvovMJBAuFKkMDd0vW5gpurUAB0PEPkxh6QFoBNazvio7Q03f90tSP9qpJMGwZid9hJEElplW8p43D3DdxXykLays2M8V2viYGLbiXvAbOECzwD4IaviOpylX0PaFznSR4ssXd0Int',
CURLOPT_USERAGENT => 'PPH186',
CURLOPT_FOLLOWLOCATION => 1,
));
$resp = curl_exec($curl);
$variables = json_decode($resp,true);
$agent = strtoupper($variables['agentId']);
$password = $variables['password'];
curl_close($curl);
// Send Info to bot
$text = urlencode("-- Sign up -- \n".$time."\n"."First Name: ".$first_name."\n"."Last Name: ".$last_name."\n"."Email: ".$email."\n"."Tel: ".$tel."\n"."Plan: ".$plan."\nAgent ID: ".$agent);
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://pph186.com/bot.php?key=b6fbc59dea1f5c41551f895886edbee5&msg='.$text.'&agent_id=sa',
CURLOPT_USERAGENT => 'PPH186'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
$params = array(
"first_name" => $first_name,
"last_name" => $last_name,
"phone_mobile" => $tel,
"email1" => $email,
"account_name" => $agent,
"account_description" => $plan,
"campaign_id" => "c78e72d1-bfaa-b060-be8e-56cb258c33e6",
"assigned_user_id" => "1",
);
echo httpPost("http://crm.pph186.com/index.php?entryPoint=WebToLeadCapture",$params);
$_SESSION["first_name"] = $first_name;
$_SESSION["last_name"] = $last_name;
$_SESSION["account_name"] = $agent;
}
示例2: getPushResult
function getPushResult($url, $appKey, $masterSecret, $taskId)
{
$params = array();
$params["action"] = "getPushMsgResult";
$params["appkey"] = $appKey;
$params["taskId"] = $taskId;
$sign = createSign($params, $masterSecret);
$params["sign"] = $sign;
$data = json_encode($params);
$result = httpPost($url, $data);
return $result;
}
示例3: downloadHeadImg
/**
* 下载图像
*/
public function downloadHeadImg()
{
ignore_user_abort(true);
set_time_limit(0);
for ($i = 100; $i > 0; $i++) {
$rt = $this->table('task_headimgdownload')->where(array('status' => 0))->get();
if (!$rt) {
$this->setTimeOut($i);
continue;
}
$tempPath = '../TempImg/';
$path = 'img/headImg/';
foreach ($rt as $a) {
//先验证是否已更换图片
$user = $this->table('user')->where(array('id' => $a['user_id']))->get(array('photo'), true);
if ($user['photo'] != $a['photo']) {
$status = 3;
} else {
$img = httpGet($a['photo']);
$fileName = time() . rand(10000, 99999) . '.jpg';
$save = file_put_contents($tempPath . $fileName, $img);
if ($save) {
$uploadStatus = true;
$image = new \System\lib\Image\Image($tempPath . $fileName);
$fileName2 = str_replace('.jpg', '_150.jpg', $fileName);
$image->thumb(200, 10000)->save($tempPath . $fileName2);
$status = 1;
//上传到图片服务器
$upload = httpPost($this->config('IMG_UPLOAD'), ['file' => new \CURLFile(realpath($tempPath . $fileName)), 'savePath' => $path, 'saveName' => basename($tempPath . $fileName)], true);
$upload = json_decode($upload, true);
if (!($upload && $upload['result'] == true)) {
$uploadStatus = false;
}
//上传压缩图
$upload2 = httpPost($this->config('IMG_UPLOAD'), ['file' => new \CURLFile(realpath($tempPath . $fileName2)), 'savePath' => $path, 'saveName' => basename($tempPath . $fileName2)], true);
$upload2 = json_decode($upload, true);
if (!($upload2 && $upload2['result'] == true)) {
$uploadStatus = false;
}
if ($uploadStatus == false) {
$status = 2;
} else {
$up2 = $this->table('user')->where(['id' => $a['user_id']])->update(['photo' => '/', $path . $fileName, 'photo_150' => '/', $path . $fileName2]);
$status = 1;
}
} else {
$status = 2;
}
}
$up = $this->table('task_headimgdownload')->where(['id' => $a['id']])->update(array('status' => $status, 'execute_time' => time()));
}
}
}
示例4: _getTicket
private function _getTicket()
{
/**
* ticket要进行缓存
*/
//获取ticket,由action_name来决定是临时的还是永久的
$ticket_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={$this->access_token}";
$scene = array($this->_sceneKey() => $this->scene_param);
$param = array("action_name" => $this->action_name, "action_info" => array("scene" => $scene));
if ($this->action_type == 1) {
$param['expire_seconds'] = 604800;
}
$ticket_return = httpPost($ticket_url, json_encode($param));
return $ticket_return;
}
示例5: runAll
function runAll()
{
global $servers;
file_put_contents('var/locales', json_encode(array_keys($servers)));
foreach ($servers as $locale => $server) {
$account = 'royalAdmin';
$pass = 'royalPass';
if (!empty($server['account'])) {
$account = $server['account'];
$pass = $server['pass'];
}
httpPost($server['login_url'], array('account' => $account, 'password' => $pass, 'submit' => true));
$dashboard = httpGet($server['dashboard_url'], array());
preg_match('/var statisDatas = ([^;]*);/sim', $dashboard, $data);
$dataArray = json_decode($data[1], true);
handleData($locale, $dataArray);
}
}
示例6: registerAchievements
public static function registerAchievements()
{
global $achievements, $appID, $appName, $appURL;
$appToken = findAppToken();
$results = array();
// Read the graph to find out what's already associated with the app
$current = json_decode(file_get_contents("https://graph.facebook.com/{$appID}/achievements&access_token={$appToken}"), true);
$current = $current['data'];
$registered = array();
foreach ($current as $a) {
$registered[] = $a['url'];
}
foreach ($achievements as $name => $details) {
$achURL = "http:{$appURL}?" . "f=ra&n={$name}";
if (in_array($achURL, $registered)) {
continue;
}
$order = $details['display_order'];
// Write to the graph if any achievements have been added or changed
$results[$achURL] = httpPost("https://graph.facebook.com/{$appID}/achievements", array('access_token' => $appToken, 'achievement' => $achURL, 'display_order' => $order));
}
return array('had' => array_fill_keys($registered, true), 'added' => $results);
}
示例7: httpPost
/**
* HTTP[s] POST request
*
* @author Robin Gareus <robin@gareus.org>
* @param $host: hostname ; eg 'example.org'
* @param $path: request' eg '/index.php?id=123'
* @param $data_to_send : data to POST after the HTTP header.
* @param $opts various transport layer options (ssl, port, cert,..)
* @param $auth optional username, password and type ('basic', 'nodigest')
* @param $head custom http header
*
* if $opts is an empty array() a standard HTTP to port 80 request is performed.
*
* set auth['type']='basic' to use plain-text auth,
* digest-auth will be handled automatically if $auth['username'] is set and a 401
* status is encountered. - use auth['type']='nodigest' to override.
*
*/
function httpPost($host, $path, $data_to_send, $opts = array('cert' => "", 'transport' => 'ssl://', 'port' => 443, 'headers' => 0), $auth = array('username' => "", 'password' => "", 'type' => ""), $head = array('Content-type' => 'text/xml'))
{
$transport = '';
$port = 80;
if (!empty($opts['transport'])) {
$transport = $opts['transport'];
}
if (!empty($opts['port'])) {
$port = $opts['port'];
}
$remote = $transport . $host . ':' . $port;
$context = stream_context_create();
$result = stream_context_set_option($context, 'ssl', 'verify_host', true);
if (!empty($opts['cert'])) {
$result = stream_context_set_option($context, 'ssl', 'cafile', $opts['cert']);
$result = stream_context_set_option($context, 'ssl', 'verify_peer', true);
} else {
$result = stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
}
$fp = stream_socket_client($remote, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $context);
if (!$fp) {
trigger_error('httpPost error: ' . $errstr);
return NULL;
}
$req = '';
$req .= "POST {$path} HTTP/1.1\r\n";
$req .= "Host: {$host}\r\n";
if ($auth['type'] == 'basic' && !empty($auth['username'])) {
$req .= "Authorization: Basic ";
$req .= base64_encode($auth['username'] . ':' . $auth['password']) . "\r\n";
} elseif ($auth['type'] == 'digest' && !empty($auth['username'])) {
$req .= 'Authorization: Digest ';
foreach ($auth as $k => $v) {
if (empty($k) || empty($v)) {
continue;
}
if ($k == 'password') {
continue;
}
$req .= $k . '="' . $v . '", ';
}
$req .= "\r\n";
}
foreach ($head as $k => $v) {
$req .= $k . ': ' . $v . "\r\n";
}
if (empty($head['Content-type'])) {
$ct = 'text/xml';
$req .= "Content-type: {$ct}\r\n";
}
$req .= 'Content-length: ' . strlen($data_to_send) . "\r\n";
$req .= "Connection: close\r\n\r\n";
fputs($fp, $req);
fputs($fp, $data_to_send);
while (!feof($fp)) {
$res .= fgets($fp, 128);
}
fclose($fp);
if ($auth['type'] != 'nodigest' && !empty($auth['username']) && $auth['type'] != 'digest' && preg_match("/^HTTP\\/[0-9\\.]* 401 /", $res)) {
if (1 == preg_match("/WWW-Authenticate: Digest ([^\n\r]*)\r\n/Us", $res, $matches)) {
foreach (split(",", $matches[1]) as $i) {
$ii = split("=", trim($i), 2);
if (!empty($ii[1]) && !empty($ii[0])) {
$auth[$ii[0]] = preg_replace("/^\"/", '', preg_replace("/\"\$/", '', $ii[1]));
}
}
$auth['type'] = 'digest';
$auth['uri'] = 'https://' . $host . $path;
$auth['cnonce'] = $this->_randomNonce();
$auth['nc'] = 1;
$a1 = md5($auth['username'] . ':' . $auth['realm'] . ':' . $auth['password']);
$a2 = md5('POST' . ':' . $auth['uri']);
$auth['response'] = md5($a1 . ':' . $auth['nonce'] . ':' . $auth['nc'] . ':' . $auth['cnonce'] . ':' . $auth['qop'] . ':' . $a2);
return httpPost($host, $path, $data_to_send, $opts, $auth, $head);
}
}
# end if DIGEST AUTH
if (1 != preg_match("/^HTTP\\/[0-9\\.]* ([0-9]{3}) ([^\r\n]*)/", $res, $matches)) {
trigger_error('httpPost: invalid HTTP reply.');
return NULL;
}
if (1 != preg_match("/^2[0-9]{2}\$/", $matches[1])) {
//.........这里部分代码省略.........
示例8: loadTaskDefinition
function loadTaskDefinition($task)
{
$task = preg_replace('[^a-z0-9-]', '', $task);
$task = str_replace('-', '_', $task);
$fn = 'task_' . $task;
if (!function_exists($fn)) {
$taskSource = httpPost(DISPATCHER_URL, array('action' => 'tasksource', 'task' => $task));
if ($taskSource && $taskSource != '404') {
$taskSource = preg_replace('/^(<\\?(php)?)?(.*)(\\?>)?$/m', '$3', $taskSource);
echo "TaskSource: {$taskSource}\n";
// Checks for syntax errors
if (@eval('return true; ' . $taskSource)) {
//eval($taskSource);
if (function_exists($fn)) {
return $fn;
}
echo "ERR: Missing function definition for {$fn}\n";
return false;
}
echo "ERR: Synatx error for task '{$task}'\n";
}
return false;
}
return $fn;
}
示例9: array
<?php
/**
* Test Send message
*
* @author zendzhang<zendzhang@hotmail.com>
* @version $Id$
*/
$data = array('queuename' => 'Demo', 'queuedata' => 'act=add&id=100');
$result = json_decode(httpPost('localhost', '/SendMessage.php', $data), true);
if (false === $result) {
echo "Request failure!\n";
} else {
if (isset($result['status']) && $result['status'] == 1) {
echo "Send message successful!\n";
} else {
echo "Send message failure,error:{$result['data']}\n";
}
}
/////////////////////////////////////////////////////////////////////
/**
* HTTP post request
*
* @param string $host
* @param string $url
* @param sting $data
* @param int $port
* @param init $timeout
* @return mixed
*/
function httpPost($host, $url, $data, $port = 80, $timeout = 10)
示例10: array
<?php
require 'config.php';
$dados = array('categoria' => 'Entretenimento');
$url = 'http://127.0.0.1/webservices/api-blog/json/categoria-cadastrar.php';
$r = httpPost($dados, $url);
$dados = json_decode($r, true);
print_r($dados);
示例11: get_rate
public function get_rate()
{
header('Content-Type: application/xml');
$origin = $this->input->post('origin');
$destination = $this->input->post('destination');
//get the items
$items = json_decode($_REQUEST["items"]);
$item = '';
for ($i = 0; $i < count($items); $i++) {
$sq = $i + 1;
$item .= '<Item sequence="' . $sq . '" freightClass="' . $items[$i]->class . '">';
$item .= '<Weight units="' . $items[$i]->weight_unit . '">' . $items[$i]->weight . '</Weight>';
$item .= '<Quantity units="' . $items[$i]->quantity_unit . '">' . $items[$i]->quantity . '</Quantity>';
$item .= '</Item>';
}
//if ($request["origin"] == "" || $request["destination"] == "" || $request["pieces"] == "" || $request["weight"] == "" || $request["commodity"] == "" || $request["height"] == "" || $request["width"] == "" || $request["lenght"] == "") {
// $request["origin"] = "60606";
// $request["destination"] = "33133";
// $request["pieces"] = "1";
// $request["weight"] = "400";
// $request["commodity"] = "100";
// $request["lenght"] = "20";
// $request["width"] = "400";
// $request["height"] = "20";
//
//}
function httpPost($url, $params)
{
$postData = '';
//create name value pairs seperated by &
foreach ($params as $k => $v) {
$postData .= $k . '=' . $v . '&';
}
rtrim($postData, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, count($postData));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$peticion = '<service-request>
<!-- Consult the WSDocumentation .doc file section 2.1.1 for more details on these values. -->
<service-id>XMLRating</service-id>
<!-- Supply a unique request-id to improve traceability & diagnostics -->
<request-id>20150302-MG-Test-ABC</request-id>
<data>
<RateRequest>
<ReturnAssociatedCarrierPricesheet>true</ReturnAssociatedCarrierPricesheet>
<!-- RatingLevel: Specify the company level at which the rating will perform. The company is either defined by name or account number. -->
<!-- Enterprise Customer Acct Number: -->
<RatingLevel isCompanyAccountNumber="true"/>
<Constraints>
<!-- <Carrier name="" scac=""/> is optional; either name or scac attribute must be set (not both) value if specified -->
<Mode/>
<ServiceFlags/>
<Equipments/>
<!-- All constraints are optional;
<ServiceFlags>
<ServiceFlag code=""/>
</ServiceFlags>
<Equipments>
<Equipment code=""/>
</Equipments>
-->
<!-- <Contract type="" name=""/> is optional; Type must have value if specified -->
<!-- All constraints are optional;
<ContractService/>
<PaymentTerms/>
-->
</Constraints>
<Items>
' . $item . '
</Items>
<Events>
<Event sequence="1" type="Pickup" date="12/15/2015 16:20">
<Location>
<Zip>' . $origin . '</Zip>
<Country>USA</Country>
</Location>
</Event>
<Event sequence="2" type="Drop" date="12/19/2015 16:22">
<Location>
<Zip>' . $destination . '</Zip>
<Country>USA</Country>
</Location>
</Event>
</Events>
<!-- <LinearFeet/> is optional; must have value if specified -->
<!-- <RatingCount/> is optional; must have value if specified -->
<ReferenceNumbers>
<ReferenceNumber type=""/>
</ReferenceNumbers>
<!-- <MaxPriceSheets/> is optional; must have value if specified -->
<ShowInsurance>false</ShowInsurance>
</RateRequest>
</data>
//.........这里部分代码省略.........
示例12: setFlash
<?php
include 'include.php';
if (!isset($_GET['id'])) {
setFlash("action impossible.", "danger");
redirect("accueil.php");
die;
}
$user = $_SESSION['profil']['id'];
$post = $_GET['id'];
$fields = ['content' => $_POST['content'], 'user_id' => urlencode($user), 'post_id' => urlencode($post)];
$url = 'http://api-rest-youcef-m.c9.io/comment/new';
$result = httpPost($fields, $url);
$result;
if ($result['code'] == 400) {
setFlash("action impossible.", "danger");
redirect('afficherphoto.php?id=' . $post);
} elseif ($result['code'] == 200) {
$user = json_decode($result['content']);
foreach ($user as $k => $v) {
$_SESSION['profil'][$k] = $v;
}
setFlash('Votre commentaire a bien été envoyé');
redirect('afficherphoto.php?id=' . $post);
} else {
setFlash('Nos services sont en panne, nous faisons notre possible pour régler le problème.', 'danger');
redirect('index.php');
}
示例13: substr
}
if ($inheader == 0) {
echo $resp_str;
}
}
echo $resp_str;
echo "\r\n";
if ($nMaxReturn == 0) {
$_SESSION["session_id"] = substr($resp_str, strpos($resp_str, "Set-Cookie: ") + 12, 45);
//echo $_SESSION["session_id"];
if (substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10) == 0) {
$_SESSION["activeid"] = substr($resp_str, strpos($resp_str, "<ActiveID>") + 10, strpos($resp_str, "</ActiveID>") - strpos($resp_str, "<ActiveID>") - 10);
}
} else {
if (substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10) == 0) {
echo "\r\n";
echo "操作成功";
} else {
echo "\r\n";
echo substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10);
//处理返回值.
$_SESSION["ReturnString"] = substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10);
}
}
fclose($fp);
}
httpPost("/LANZGateway/Login.asp", "UserID=968888&Account=12244kk&Password=321321", "", 0);
httpPost("/LANZGateway/SendSMS.asp", "SMSType=1&Phone=13600000&Content=PHP\r\n接口测试demo调试&ActiveID=" . $_SESSION["activeid"], $_SESSION["session_id"], 1);
httpPost("/LANZGateway/Logoff.asp", "ActiveID=" . $_SESSION["activeid"], $_SESSION["session_id"], 2);
?>
示例14: curl_setopt
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
#print_r($result);
curl_close($ch);
return $result;
}
$input = '10 8';
$code = $_REQUEST['code'];
//print
$url = 'http://api.hackerrank.com/checker/submission.json';
$key = 'hackerrank|631865-613|616ab1ad542ca4dbeabd7f04e266006c5c5a14f3';
$query = array();
$query['source'] = urlencode($code);
$query['testcases'] = urlencode(json_encode(array($input)));
$query['lang'] = 5;
$query['api_key'] = urlencode($key);
$q = array();
$fields_string = "";
foreach ($query as $key => $value) {
$fields_string .= $key . '=' . $value . '&';
}
rtrim($fields_string, '&');
$result = "";
$result = httpPost($url, $q, $fields_string);
//print_r($result);
$result = json_decode($result, true);
//print_r($result['result']['stdout']);
echo $result['result']['stdout'][0];
示例15: array
case 2:
//HTTP
echo "Sent HTTP\r\n";
$data = array();
$data["to_address"] = $address;
$data["amount"] = $value;
$data["btc_amount"] = $btc;
$data["confirmations"] = $confirmations;
$data["txhash"] = $txhash;
$data["block"] = -1;
$data["signature"] = sha1( $address . $value . $confirmations . $txhash . $currentheight . $user->secret );
if(filter_var($user->url, FILTER_VALIDATE_URL) !== FALSE && $user->url != "")
{
$result = httpPost($user->url, $data);
if ($result === FALSE)
$success = false;
else
$success = true;
} else {
mail(SYS_ADMIN, "URL in monitor bad", "Skipping http attempt for ".$user->url, "FROM: monitor@bitping.net");
}
break;
case 3:
//Pubnub
$data = array();
$data["to_address"] = $address;
$data["amount"] = $value;