本文整理匯總了PHP中Http::doPost方法的典型用法代碼示例。如果您正苦於以下問題:PHP Http::doPost方法的具體用法?PHP Http::doPost怎麽用?PHP Http::doPost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Http
的用法示例。
在下文中一共展示了Http::doPost方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: send
function send($phones, $msg, $send_date = '', $send_num = 1, $sms_type = '', $version = '1.0', &$sms_error = '')
{
//function send($phones, $msg, &$sms_error = '') {
/* 檢查發送信息的合法性 */
$contents = $this->get_contents($phones, $msg);
if (!$contents) {
return false;
}
/* 獲取API URL */
$sms_url = "http://106.ihuyi.com/webservice/sms.php?method=Submit";
if (count($contents) > 1) {
foreach ($contents as $key => $val) {
$post_data = "account=" . $this->sms_name . "&password=" . md5($this->sms_password) . "&mobile=" . $val['phones'] . "&content=" . rawurlencode($val['content']);
//密碼可以使用明文密碼或使用32位MD5加密
//$get = $this->Post($post_data, $sms_url);
$get = Http::doPost($sms_url, $post_data);
$gets = $this->xml_to_array($get);
sleep(1);
}
} else {
$post_data = "account=" . $this->sms_name . "&password=" . md5($this->sms_password) . "&mobile=" . $contents[0]['phones'] . "&content=" . rawurlencode($contents[0]['content']);
//密碼可以使用明文密碼或使用32位MD5加密
//$get = $this->Post($post_data, $sms_url);
$get = Http::doPost($sms_url, $post_data);
$gets = $this->xml_to_array($get);
}
//print_r($gets);exit; //開啟調試模式
if ($gets['SubmitResult']['code'] == 2) {
return true;
} else {
$sms_error = $gets['SubmitResult']['msg'];
$this->logResult($sms_error);
return false;
}
}
示例2: get_code
/**
* 生成支付代碼
*
* @param array $order 訂單信息
* @param array $payment 支付方式信息
*/
function get_code($order, $payment)
{
$init_url = 'https://wap.tenpay.com/cgi-bin/wappayv2.0/wappay_init.cgi';
$gateway = 'https://wap.tenpay.com/cgi-bin/wappayv2.0/wappay_gate.cgi';
// 初始化
$data = array('ver' => '2.0', 'charset' => 1, 'bank_type' => 0, 'desc' => $order['order_sn'], 'bargainor_id' => $payment['bargainor_id'], 'sp_billno' => $order['order_sn'] . 'O' . $order['log_id'], 'total_fee' => $order['order_amount'] * 100, 'fee_type' => 1, 'notify_url' => return_url(basename(__FILE__, '.php'), array('type' => 0)), 'callback_url' => return_url(basename(__FILE__, '.php'), array('type' => 1)));
// 字典排序
ksort($data);
reset($data);
// 生成簽名
$sign = '';
foreach ($data as $key => $vo) {
if ($vo !== '') {
$sign .= $key . '=' . $vo . '&';
}
}
$sign .= 'key=' . $payment['tenpay_key'];
$data['sign'] = strtoupper(md5($sign));
// 交易初始化
$result = Http::doPost($init_url, $data);
$xml = (array) simplexml_load_string($result);
if (isset($xml['err_info'])) {
return '<div style="color:red; text-align: center">錯誤信息:' . $xml['err_info'] . '</div>';
}
/* 生成支付按鈕 */
$button = '<div><input type="button" class="btn btn-info ect-btn-info ect-colorf ect-bg" onclick="window.open(\'' . $gateway . '?token_id=' . $xml['token_id'] . '\')" value="' . L('pay_button') . '" class="c-btn3" /></div>';
return $button;
}
示例3: doRequest
public static function doRequest($url, $param)
{
$returnVal = Http::doPost($url, $param);
if ($returnVal) {
return json_decode($returnVal);
} else {
return false;
}
}
示例4: get_code
/**
* 生成支付代碼
*
* @param array $order
* 訂單信息
* @param array $payment
* 支付方式信息
*/
function get_code($order, $payment)
{
if (!defined('EC_CHARSET')) {
$charset = 'utf-8';
} else {
$charset = EC_CHARSET;
}
$gateway = 'http://wappaygw.alipay.com/service/rest.htm?';
// 請求業務數據
$req_data = '<direct_trade_create_req>' . '<subject>' . $order['order_sn'] . '</subject>' . '<out_trade_no>' . $order['order_sn'] . 'O' . $order['log_id'] . '</out_trade_no>' . '<total_fee>' . $order['order_amount'] . '</total_fee>' . '<seller_account_name>' . $payment['alipay_account'] . '</seller_account_name>' . '<call_back_url>' . return_url(basename(__FILE__, '.php'), array('type' => 0)) . '</call_back_url>' . '<notify_url>' . return_url(basename(__FILE__, '.php'), array('type' => 1)) . '</notify_url>' . '<out_user>' . $order['consignee'] . '</out_user>' . '<merchant_url>' . __URL__ . '</merchant_url>' . '<pay_expire>3600</pay_expire>' . '</direct_trade_create_req>';
$parameter = array('service' => 'alipay.wap.trade.create.direct', 'format' => 'xml', 'v' => '2.0', 'partner' => $payment['alipay_partner'], 'req_id' => $order['order_sn'] . $order['log_id'], 'sec_id' => 'MD5', 'req_data' => $req_data, "_input_charset" => $charset);
ksort($parameter);
reset($parameter);
$param = '';
$sign = '';
foreach ($parameter as $key => $val) {
$param .= "{$key}=" . urlencode($val) . "&";
$sign .= "{$key}={$val}&";
}
$param = substr($param, 0, -1);
$sign = substr($sign, 0, -1) . $payment['alipay_key'];
// 請求授權接口
$result = Http::doPost($gateway, $param . '&sign=' . md5($sign));
$result = urldecode($result);
// URL轉碼
$result_array = explode('&', $result);
// 根據 & 符號拆分
// 重構數組
$new_result_array = $temp_item = array();
if (is_array($result_array)) {
foreach ($result_array as $vo) {
$temp_item = explode('=', $vo, 2);
// 根據 & 符號拆分
$new_result_array[$temp_item[0]] = $temp_item[1];
}
}
$xml = simplexml_load_string($new_result_array['res_data']);
$request_token = (array) $xml->request_token;
// 請求交易接口
$parameter = array('service' => 'alipay.wap.auth.authAndExecute', 'format' => 'xml', 'v' => $new_result_array['v'], 'partner' => $new_result_array['partner'], 'sec_id' => $new_result_array['sec_id'], 'req_data' => '<auth_and_execute_req><request_token>' . $request_token[0] . '</request_token></auth_and_execute_req>', 'request_token' => $request_token[0], '_input_charset' => $charset);
ksort($parameter);
reset($parameter);
$param = '';
$sign = '';
foreach ($parameter as $key => $val) {
$param .= "{$key}=" . urlencode($val) . "&";
$sign .= "{$key}={$val}&";
}
$param = substr($param, 0, -1);
$sign = substr($sign, 0, -1) . $payment['alipay_key'];
/* 生成支付按鈕 */
//$button = '<script type="text/javascript" src="'.__PUBLIC__.'/js/ap.js"></script><div><input type="button" class="btn btn-info ect-btn-info ect-colorf ect-bg l-pay-btn" onclick="javascript:_AP.pay(\'' . $gateway . $param . '&sign=' . md5($sign) . '\')" value="' . L('pay_button') . '" class="c-btn3" /></div>';
$button = '<script type="text/javascript" src="' . __PUBLIC__ . '/js/ap.js"></script><input type="button" class="btn btn-info ect-btn-info ect-colorf ect-bg l-pay-btn" onclick="javascript:_AP.pay(\'' . $gateway . $param . '&sign=' . md5($sign) . '\')" value="' . L('pay_button') . '" class="c-btn3" />';
return $button;
}
示例5: test002
public function test002()
{
$param = array("order_no" => "11111", "id" => "22222");
$returnVal = Http::doPost("http://192.168.1.28:8088/quanpinMIS/doA0211.iss", $param);
$returnObj = json_decode($returnVal);
if ($returnObj->returnVal == "OK") {
// OK
} else {
// NG
}
}
示例6: run
/**
* 請求
* @param type $data
* @return type
*/
private function run($data)
{
$fields = array('data' => json_encode($data), 'version' => VERSION, 'release' => RELEASE, 'act' => $this->act, 'identity' => $data['appid'], 'token' => $this->token);
//請求
$status = Http::doPost(self::serverHot, $fields);
if (false == $status) {
$this->error = '無法聯係服務器,請稍後再試!';
return false;
}
return $this->returnResolve($status);
}
示例7: json_decode
$token = json_decode($data_token);
//發貨通知微信
$url1 = 'https://api.weixin.qq.com/pay/delivernotify?access_token=' . $token->access_token;
$data1 = Http::doPost($url1, $data, 5, '', 'json');
$rs1 = json_decode($data1);
//成功通知微信
if ($rs1->errcode == 0) {
//echo 'success';
} else {
//獲取access_token
$url_token1 = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $payment['wxpay_appid'] . '&secret=' . $payment['wxpay_appsecret'];
$data_token1 = Http::doGet($url_token1);
$token1 = json_decode($data_token1);
//第一次失敗再次發送發貨通知微信
$url2 = 'https://api.weixin.qq.com/pay/delivernotify?access_token=' . $token1->access_token;
$data2 = Http::doPost($url2, $data, 5, '', 'json');
$rs2 = json_decode($data2);
if ($rs2->errcode == 0) {
//echo 'success';
} else {
exit($rs2->errcode . ':' . $rs2->errmsg);
}
}
}
//打印日誌
function logResult($word = '')
{
$fp = fopen("log.txt", "a");
flock($fp, LOCK_EX);
fwrite($fp, "執行日期:" . strftime("%Y%m%d%H%M%S", time()) . "\n" . $word . "\n");
flock($fp, LOCK_UN);