- 虚拟支付 mp_sig签名一直抱错?
[代码][代码] [代码] [代码][代码][代码] [代码][代码]function[代码] [代码]request_post([代码][代码]$url[代码] [代码], [代码][代码]$post_data[代码] [代码])[代码][代码][代码][代码] [代码][代码]{[代码][代码][代码][代码] [代码][代码]$data_string[代码] [代码]= json_encode([代码][代码]$post_data[代码][代码]);[代码][代码][代码][代码] [代码][代码]$ch[代码] [代码]= curl_init ();[代码][代码][代码][代码] [代码][代码]curl_setopt ( [代码][代码]$ch[代码][代码], CURLOPT_URL, [代码][代码]$url[代码] [代码]);[代码][代码][代码][代码] [代码][代码]curl_setopt ( [代码][代码]$ch[代码][代码], CURLOPT_POST, 1 );[代码][代码][代码][代码] [代码][代码]curl_setopt([代码][代码]$ch[代码][代码], CURLOPT_HEADER, false);[代码][代码][代码][代码] [代码][代码]curl_setopt([代码][代码]$ch[代码][代码], CURLOPT_SSL_VERIFYPEER, false);[代码][代码][代码][代码] [代码][代码]// curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");[代码][代码][代码][代码] [代码][代码]curl_setopt([代码][代码]$ch[代码][代码], CURLOPT_POSTFIELDS,[代码][代码]$data_string[代码][代码]);[代码][代码][代码][代码] [代码][代码]curl_setopt([代码][代码]$ch[代码][代码], CURLOPT_RETURNTRANSFER,true);[代码][代码][代码][代码] [代码][代码]curl_setopt([代码][代码]$ch[代码][代码], CURLOPT_HTTPHEADER, [代码][代码]array[代码][代码]([代码][代码][代码][代码] [代码][代码]'Content-Type: application/json'[代码][代码],[代码][代码][代码][代码] [代码][代码]'Content-Length: '[代码] [代码]. [代码][代码]strlen[代码][代码]([代码][代码]$data_string[代码][代码])[代码][代码][代码][代码] [代码][代码]));[代码][代码][代码][代码] [代码][代码]$result[代码] [代码]= curl_exec([代码][代码]$ch[代码][代码]);[代码][代码][代码][代码] [代码][代码]if[代码] [代码](curl_errno([代码][代码]$ch[代码][代码])) {[代码][代码][代码][代码] [代码][代码]print[代码] [代码]curl_error([代码][代码]$ch[代码][代码]);[代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码] [代码][代码]curl_close([代码][代码]$ch[代码][代码]);[代码][代码][代码][代码] [代码][代码]return[代码] [代码]$result[代码] [代码];[代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码] [代码][代码]//创建签名 [代码][代码][代码][代码] [代码][代码]function[代码] [代码]create_sig( [代码][代码]$post_data[代码] [代码],[代码][代码]$appKey[代码][代码])[代码][代码][代码][代码] [代码][代码]{[代码][代码][代码][代码] [代码][代码]ksort([代码][代码]$post_data[代码][代码]);[代码][代码][代码][代码] [代码][代码]$o[代码] [代码]= [代码][代码]""[代码][代码];[代码][代码][代码][代码] [代码][代码]foreach[代码] [代码]( [代码][代码]$post_data[代码] [代码]as[代码] [代码]$k[代码] [代码]=> [代码][代码]$v[代码] [代码]) [代码][代码][代码][代码] [代码][代码]{ [代码][代码][代码][代码] [代码][代码]$o[代码][代码].= [代码][代码]"$k="[代码] [代码]. rawurlencode( [代码][代码]$v[代码] [代码]). [代码][代码]"&"[代码] [代码];[代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码] [代码][代码]$stringA[代码] [代码]= [代码][代码]substr[代码][代码]([代码][代码]$o[代码][代码],0,-1);[代码][代码][代码][代码] [代码][代码]// stringA+"&org_loc=/cgi-bin/midas/getbalance&method=POST&secret=zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u"[代码][代码][代码][代码] [代码][代码]$stringSignTemp[代码][代码]=[代码][代码]$stringA[代码][代码].[代码][代码]"&org_loc=/cgi-bin/midas/getbalance&method=POST&secret="[代码][代码].[代码][代码]$appKey[代码][代码];[代码][代码][代码][代码] [代码][代码]// file_put_contents ( 'create_sig.log', $stringSignTemp . PHP_EOL, FILE_APPEND | LOCK_EX );[代码][代码][代码][代码] [代码][代码]$s[代码] [代码]= hash_hmac([代码][代码]'sha256'[代码][代码], [代码][代码]$stringSignTemp[代码][代码], [代码][代码]$appKey[代码][代码], false);[代码][代码][代码][代码] [代码][代码]// $s = hash_hmac('sha256', $stringSignTemp, strtr($appKey, '-_', '+/'), true);[代码][代码][代码][代码] [代码][代码]// $sig = base64_encode($s);[代码][代码][代码][代码] [代码][代码]$sig[代码] [代码]= [代码][代码]$s[代码] [代码];[代码][代码][代码][代码] [代码][代码]return[代码] [代码]$sig[代码][代码];[代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码] [代码][代码]function[代码] [代码]create_mp_sig( [代码][代码]$post_data[代码][代码],[代码][代码]$session_key[代码][代码])[代码][代码][代码][代码] [代码][代码]{[代码][代码][代码][代码] [代码] [代码][代码][代码] [代码][代码]ksort([代码][代码]$post_data[代码][代码]);[代码][代码][代码][代码] [代码][代码]$o[代码] [代码]= [代码][代码]""[代码][代码];[代码][代码][代码][代码] [代码][代码]foreach[代码] [代码]( [代码][代码]$post_data[代码] [代码]as[代码] [代码]$k[代码] [代码]=> [代码][代码]$v[代码] [代码]) [代码][代码][代码][代码] [代码][代码]{ [代码][代码][代码][代码] [代码][代码]$o[代码][代码].= [代码][代码]"$k="[代码] [代码]. rawurlencode( [代码][代码]$v[代码] [代码]). [代码][代码]"&"[代码] [代码];[代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码] [代码][代码]$stringA[代码] [代码]= [代码][代码]substr[代码][代码]([代码][代码]$o[代码][代码],0,-1);[代码][代码][代码][代码] [代码][代码]//$stringSignTemp=stringA+"&org_loc=/cgi-bin/midas/getbalance&method=POST&session_key=V7Q38/i2KXaqrQyl2Yx9Hg=="[代码][代码][代码][代码] [代码][代码]$stringSignTemp[代码][代码]=[代码][代码]$stringA[代码][代码].[代码][代码]"&org_loc=/cgi-bin/midas/getbalance&method=POST&session_key="[代码][代码].[代码][代码]$session_key[代码][代码];[代码][代码][代码][代码] [代码][代码]file_put_contents[代码] [代码]( [代码][代码]'create_mp_sig.log'[代码][代码], [代码][代码]$stringSignTemp[代码] [代码]. PHP_EOL, FILE_APPEND | LOCK_EX );[代码][代码][代码][代码] [代码][代码]$s[代码] [代码]= hash_hmac([代码][代码]'sha256'[代码][代码], [代码][代码]$stringSignTemp[代码][代码], [代码][代码]$session_key[代码][代码], false);[代码][代码][代码][代码] [代码][代码]// $s = hash_hmac('sha256', $stringSignTemp, strtr($session_key, '-_', '+/'), true);[代码][代码][代码][代码] [代码][代码]// $sig = base64_encode($s);[代码][代码][代码][代码] [代码][代码]$sig[代码] [代码]= [代码][代码]$s[代码] [代码];[代码][代码][代码][代码] [代码][代码]return[代码] [代码]$sig[代码][代码];[代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码] [代码][代码]$datastr[代码] [代码]= [代码][代码]file_get_contents[代码][代码]([代码][代码]'php://input'[代码][代码]);[代码][代码][代码][代码] [代码][代码]$data[代码] [代码]= json_decode([代码][代码]$datastr[代码][代码],true);[代码][代码][代码][代码] [代码][代码]// file_put_contents ( 'debug2222.log', var_export($data,true) . PHP_EOL, FILE_APPEND | LOCK_EX );[代码][代码][代码][代码] [代码] [代码][代码][代码] [代码][代码]$appSecret[代码] [代码]= [代码][代码]"修改xxx"[代码][代码];[代码][代码][代码][代码] [代码][代码]$appid[代码] [代码]= [代码][代码]"修改"[代码][代码];[代码][代码][代码][代码] [代码][代码]$offer_id[代码] [代码]= [代码][代码]"修改"[代码][代码]; [代码][代码]//米大师分配的offer_id[代码][代码][代码][代码] [代码] [代码][代码][代码] [代码][代码]$openid[代码] [代码]= [代码][代码]$data[代码][代码][[代码][代码]"openid"[代码][代码]]; [代码][代码]//[代码][代码][代码][代码] [代码][代码]$access_token[代码] [代码]= [代码][代码]$data[代码][代码][[代码][代码]"access_token"[代码][代码]];[代码][代码][代码][代码] [代码][代码]$session_key[代码] [代码]= [代码][代码]$data[代码][代码][[代码][代码]"session_key"[代码][代码]];[代码][代码][代码][代码] [代码][代码]$ts[代码] [代码]= time();[代码][代码][代码][代码] [代码][代码]$zone_id[代码] [代码]= [代码][代码]"1"[代码][代码];[代码][代码][代码][代码] [代码][代码]$pf[代码] [代码]= [代码][代码]"android"[代码][代码];[代码][代码][代码][代码] [代码][代码]$test[代码] [代码]= true;[代码][代码][代码][代码] [代码][代码]//正式[代码][代码][代码][代码] [代码][代码]$api[代码] [代码]= [代码][代码]"https://api.weixin.qq.com/cgi-bin/midas/getbalance?access_token=$access_token"[代码][代码];[代码][代码][代码][代码] [代码][代码]$offerSecret[代码] [代码]= [代码][代码]"修改"[代码][代码];[代码][代码][代码][代码] [代码][代码]//测试[代码][代码][代码][代码] [代码][代码]if[代码][代码]([代码][代码]$test[代码][代码])[代码][代码][代码][代码] [代码][代码]{[代码][代码][代码][代码] [代码][代码]$api[代码] [代码]= [代码][代码]"https://api.weixin.qq.com/cgi-bin/midas/sandbox/getbalance?access_token=$access_token"[代码][代码];[代码][代码][代码][代码] [代码][代码]$offerSecret[代码] [代码]= [代码][代码]"修改"[代码][代码];[代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码] [代码][代码]if[代码][代码](isset([代码][代码]$openid[代码][代码]))[代码][代码][代码][代码] [代码][代码]{[代码][代码][代码][代码] [代码][代码]$dataArr[代码] [代码]= [代码][代码]array[代码][代码]([代码][代码]"openid"[代码][代码]=>[代码][代码]$openid[代码][代码],[代码][代码]"appid"[代码][代码]=>[代码][代码]$appid[代码][代码],[代码][代码]"offer_id"[代码][代码]=>[代码][代码]$offer_id[代码][代码],[代码][代码]"ts"[代码][代码]=>[代码][代码]$ts[代码][代码],[代码][代码]"zone_id"[代码][代码]=>[代码][代码]$zone_id[代码][代码],[代码][代码]"pf"[代码][代码]=>[代码][代码]$pf[代码][代码]);[代码][代码][代码][代码] [代码][代码]$testSign1[代码] [代码]= create_sig([代码][代码]$dataArr[代码][代码],[代码][代码]$offerSecret[代码][代码]);[代码][代码][代码][代码] [代码][代码]$dataArr2[代码] [代码]= [代码][代码]array[代码][代码]([代码][代码]"openid"[代码][代码]=>[代码][代码]$openid[代码][代码],[代码][代码]"appid"[代码][代码]=>[代码][代码]$appid[代码][代码],[代码][代码]"offer_id"[代码][代码]=>[代码][代码]$offer_id[代码][代码],[代码][代码]"ts"[代码][代码]=>[代码][代码]$ts[代码][代码],[代码][代码]"zone_id"[代码][代码]=>[代码][代码]$zone_id[代码][代码],[代码][代码]"pf"[代码][代码]=>[代码][代码]$pf[代码][代码],[代码][代码]"access_token"[代码][代码]=>[代码][代码]$access_token[代码][代码],[代码][代码]"sig"[代码][代码]=>[代码][代码]$testSign1[代码][代码]);[代码][代码][代码][代码] [代码][代码]$mp_sig[代码] [代码]= create_mp_sig([代码][代码]$dataArr2[代码][代码],[代码][代码]$session_key[代码][代码]);[代码][代码][代码][代码] [代码][代码]$dataArr3[代码] [代码]= [代码][代码]array[代码][代码]([代码][代码]"openid"[代码][代码]=>[代码][代码]$openid[代码][代码],[代码][代码]"appid"[代码][代码]=>[代码][代码]$appid[代码][代码],[代码][代码]"offer_id"[代码][代码]=>[代码][代码]$offer_id[代码][代码],[代码][代码]"ts"[代码][代码]=>[代码][代码]$ts[代码][代码],[代码][代码]"zone_id"[代码][代码]=>[代码][代码]$zone_id[代码][代码],[代码][代码]"pf"[代码][代码]=>[代码][代码]$pf[代码][代码],[代码][代码]"access_token"[代码][代码]=>[代码][代码]$access_token[代码][代码],[代码][代码]"sig"[代码][代码]=>[代码][代码]$testSign1[代码][代码],[代码][代码]"mp_sig"[代码][代码]=>[代码][代码]$mp_sig[代码][代码]);[代码][代码][代码][代码] [代码][代码]$result[代码] [代码]= request_post([代码][代码]$api[代码][代码],[代码][代码]$dataArr3[代码][代码]);[代码][代码][代码][代码] [代码][代码]file_put_contents[代码] [代码]( [代码][代码]'debug333.log'[代码][代码], var_export([代码][代码]$dataArr3[代码][代码],true) . PHP_EOL, FILE_APPEND | LOCK_EX );[代码][代码][代码][代码] [代码][代码]file_put_contents[代码] [代码]( [代码][代码]'debug2222.log'[代码][代码], [代码][代码]$result[代码] [代码]. PHP_EOL, FILE_APPEND | LOCK_EX );[代码][代码][代码][代码] [代码][代码]print_r([代码][代码]$result[代码][代码]);[代码][代码][代码][代码] [代码][代码]// $dataArrTest = array("openid"=>"odkx20ENSNa2w5y3g_qOkOvBNM1g","appid"=>"wx1234567","offer_id"=>"12345678","ts"=>"1507530737","zone_id"=>pf,"sig"=>"1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b","access_token"=>"ACCESSTOKEN");[代码][代码][代码][代码] [代码][代码]// $sigTest = create_mp_sig($dataArrTest,"V7Q38/i2KXaqrQyl2Yx9Hg==");[代码][代码][代码][代码] [代码][代码]// file_put_contents ( 'test.log', $sigTest . PHP_EOL, FILE_APPEND | LOCK_EX );[代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码]?>[代码][代码] 在接内购 ,一直卡在 mp_sig 抱错 :{"errcode":90009,"errmsg":"mp_sig error hint: [r16KCA0903e257]"} 可是这个算法 用上微信官方的例子给出的参数 是和文档一模一样的 。为什么实际测试就会出现mp_sig 这个算法我已经参照文档反复比对。还是抱这个错,哪位大佬能指正下到底是哪里出问题了。文档参照的: https://developers.weixin.qq.com/minigame/dev/tutorial/open-ability/midas-signature.html
2018-06-05 - 这种批处理类型的shader微信小游戏抱错
合并类型的shader模式在微信真机里无法运行,一直抱错expert Num错误。 h5下是可以运行的 shader如下: var vsh = "precision mediump float;" + "attribute vec4 a_position;" + "uniform mat4 mvpMatrix;"+ "uniform vec4 a_color;"+ "varying vec4 vColor;"+ "varying vec2 texCoord;" + "void main()" + "{" + "vColor = a_color;"+ " texCoord = a_position.zw;" + " gl_Position = mvpMatrix * vec4(a_position.xy,0.0,1.0);" + "}"; var fsh = "precision mediump float;" + "varying vec2 texCoord;" + "uniform sampler2D inputImageTexture;"+ "varying vec4 vColor;"+ "void main()" + "{" + " gl_FragColor = texture2D(inputImageTexture,texCoord)*vColor ; " + "}";
2018-05-31