string url= "xxx.php";
10年積累的成都做網(wǎng)站、成都網(wǎng)站設(shè)計、成都外貿(mào)網(wǎng)站建設(shè)經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有安順免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(uri);
hwr.Method = requestMethod.ToString();
hwr.KeepAlive = true;
hwr.Timeout = 60 * 1000;
hwr.ContentLength = byteArray.Length;
using (Stream rqStream = hwr.GetRequestStream())
{
string requstData = "aa=bbb";
byte[] byteArray = Encoding.UTF8.GetBytes(requstData);
rqStream.Write(byteArray, 0, byteArray.Length);
rqStream.Dispose();
}
string resultStr ="";
using (WebResponse resp = hwr.GetResponse())
{
Stream rpStream = resp.GetResponseStream();
StreamReader sr = new StreamReader(rpStream);
resultStr = sr.ReadToEnd();
rpStream.Dispose();
}
//返回字符串 處理 resultStr
PAY頁面往 js_api_call.php 傳值 獲取不到的問題
echo 是可以echo出來的 但是
這里不寫死就會報錯 $key0$
?php
/**
* JS_API支付demo
* ====================================================
* 在微信瀏覽器里面打開H5網(wǎng)頁中執(zhí)行JS調(diào)起支付。接口輸入輸出數(shù)據(jù)格式為JSON。
* 成功調(diào)起支付需要三個步驟:
* 步驟1:網(wǎng)頁授權(quán)獲取用戶openid
* 步驟2:使用統(tǒng)一支付接口,獲取prepay_id
* 步驟3:使用jsapi調(diào)起支付
*/
//獲取信息
@$name="支付測試-包包";
@$price=0.01*100;
@$hyid=$_GET['hyid'];
@$out_trade_no=$_GET['num'];//訂單號
include_once("../WxPayPubHelper/WxPayPubHelper.php");
//使用jsapi接口
$jsApi = new JsApi_pub();
//=========步驟1:網(wǎng)頁授權(quán)獲取用戶openid============
陪猛 //通過code獲得openid
if (!isset($_GET['code']))
{
//觸發(fā)微信返回code碼
$url = $jsApi-createOauthUrlForCode(WxPayConf_pub::JS_API_CALL_URL);
Header("Location: $url");
}else
{
//獲取code碼,以獲取openid
$code = $_GET['code'];
纖纖$jsApi-setCode($code);
$openid = $jsApi-getOpenId();
}
//=========步驟2:使用統(tǒng)一支付接口,獲取prepay_id============
//使用統(tǒng)一支付接口
$unifiedOrder = new UnifiedOrder_pub();
//設(shè)置統(tǒng)一支付接口參數(shù)
//設(shè)置必填參數(shù)
//appid已填,商戶無需重復(fù)填寫
//mch_id已填,商戶無需重復(fù)填寫
//noncestr已填,商戶無需重復(fù)填寫
//spbill_create_ip已填,商戶無需重復(fù)填寫
//sign已填,商戶無需重復(fù)填寫
$unifiedOrder-setParameter("openid","$openid");//商品描述
$unifiedOrder-setParameter("body","$name");//商品描述
//自定義訂單號,此處僅作舉例
$timeStamp = time();
$out_trade_no = WxPayConf_pub::APPID."$timeStamp";
$unifiedOrder-setParameter("out_trade_no","$out_trade_no");//商戶訂單號
$unifiedOrder-setParameter("total_fee","$price");//總金額
$unifiedOrder-setParameter("notify_url","");//通知地址
$unifiedOrder-setParameter("trade_type","JSAPI");//交易類型
//非必填參數(shù),商戶可根據(jù)實際情況選填
//$unifiedOrder-setParameter("sub_mch_id","XXXX");//子商戶號
//$unifiedOrder-setParameter("device_info","XXXX");//設(shè)備號
//$unifiedOrder-setParameter("attach","XXXX");//附加毀亂仿數(shù)據(jù)
//$unifiedOrder-setParameter("time_start","XXXX");//交易起始時間
//$unifiedOrder-setParameter("time_expire","XXXX");//交易結(jié)束時間
//$unifiedOrder-setParameter("goods_tag","XXXX");//商品標(biāo)記
$unifiedOrder-setParameter("attach","2");//會員ID
$prepay_id = $unifiedOrder-getPrepayId();
//=========步驟3:使用jsapi調(diào)起支付============
$jsApi-setPrepayId($prepay_id);
$jsApiParameters = $jsApi-getParameters();
//echo $jsApiParameters;
?
html
head
meta charset="utf-8"
title支付頁面/title
script type="text/javascript"
//調(diào)用微信JS api 支付
function jsApiCall()
{
WeixinJSBridge.invoke(
'getBrandWCPayRequest',
?php echo $jsApiParameters; ?,
function(res){
WeixinJSBridge.log(res.err_msg);
if(res.err_msg == "get_brand_wcpay_requestk"){
window.location.href='/shop/successful.php?spmc=?php echo $name; ?price=?php echo $price; ?';
//history.go(-1);
}else{
window.location.href='/shop/pay.php';
}
}
);
}
if (typeof WeixinJSBridge == "undefined"){
if( document.addEventListener ){
document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
}else if (document.attachEvent){
document.attachEvent('WeixinJSBridgeReady', jsApiCall);
document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
}
}else{
jsApiCall();
}
/script
/head
/html
調(diào)用小程序文件上傳api
服務(wù)器接收到微信post過來的文件之后,php處理代碼和傳統(tǒng)文件上傳代碼一樣