分享你我的心得.
共乘一片美好网络.

查询代金券批次详情,提示“api请求失败!”,状态码405或是签名错误

下面矫正一下

提交的URL

$url = self::$base_url.'stocks/'.$stock_id.'?stock_creator_mchid='.$params['stock_creator_mchid'];

必须是GET请求,body=””

代码如下:

Function voucher_juan_cx(stock_creator_mchid,stock_id)
dim sXML
sXML="stock_creator_mchid="&stock_creator_mchid&""
A="GET"'GET\POST提交方式
B="/v3/marketing/favor/stocks/"&stock_id&"?"&sXML&""'URL去除域名
Datas=A&""&CHR(10)&""&B&""&CHR(10)&""&timestamp&""&CHR(10)&""&nonce_str&""&CHR(10)&""&CHR(10)
signature=Encrypt.Sign(Datas,"Null",Privatekey,"SHA256","4.0.30319")
Set https = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")
      https.setOption(2) = 13056
      'https.setOption(3)="LOCAL_MACHINE\My\证书位置"
      https.setTimeouts 10 * 100, 10 * 100, 10 * 100, 10 * 100
With https
.Open ""&A&"", "https://api.mch.weixin.qq.com/v3/marketing/favor/stocks/"&stock_id&"?"&sXML&"", False
           https.SetRequestHeader "Content-Type","application/json"
           https.SetRequestHeader "Accept","application/json"
           https.SetRequestHeader "Accept-Language","zh-CN"
           https.SetRequestHeader "Authorization","WECHATPAY2-SHA256-RSA2048 mchid="""&mchid&""",nonce_str="""&nonce_str&""",timestamp="""&timestamp&""",serial_no="""&serial_no&""",signature="""&signature&""""
.Send ""
voucher_juan_cx = .ResponseBody
End With 
voucher_juan_cx = BytesToBstr(voucher_juan_cx,"utf-8")
Set https = Nothing 
End Function
赞(0)
未经允许不得转载:小叶白龙博客 » 查询代金券批次详情,提示“api请求失败!”,状态码405或是签名错误
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!