小程序模板消息运行不报错但手机就是没有消息发过来,为什么
2019-04-03 15:16:50
如何看待微信公开课小程序热门讨论「小程序模板消息运行不报错但手机就是没有消息发过来,为什么」
摘要:小程序模板消息运行不报错但手机就是没有消息发过来,为什么
展开:在学模板消息时,获得了openid、formid等,运行不报错,但手机真机上就是没有消息发过来,为什么跪求大神指教,调试好多天了。代码如下://app.jsApp({openid:null,onLaunch:function(){varthatthis;wx.login({success:function(res){wx.request({url:https://pinke.applinzi.com/login.php,//仅为示例,并非真实的接口地址data:{code:res.code},header:{contenttype:application/json//默认值},success:function(res){vardatares.data;varopeniddata.openid;that.openidopenid;}})},});}})//index.js//获取应用实例constappgetApp()Page({data:{},onLoad:function(){//console.log(hahah:+app.openid);},formSubmit:function(e){varopenidapp.openid;varformide.detail.formId;vargoosee.detail.value.goose;varaddresse.detail.value.address;vartimee.detail.value.time;console.log(e);console.log(wosh是formid:+formid);console.log(wosh是GOOSE:+goose);wx.request({url:https://pinke.applinzi.com/moban.php,data:{openid:openid,time:time,address:address,goose:goose,formid:formid},header:{contenttype:application/json//默认值},success:function(res){console.log(res.data)console.log(已经成功回调request)}})}})后台php:?phpfunctionhttpPost($data,$url){$chcurl_init();//初始化curlcurl_setopt($ch,CURLOPT_URL,$url);//抓取指定网页curl_setopt($ch,CURLOPT_CUSTOMREQUEST,POST);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);curl_setopt($ch,CURLOPT_USERAGENT,Mozilla/5.0(compatible;MSIE5.01;windowsNT5.0));curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);curl_setopt($ch,CURLOPT_AUTOREFERER,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$data);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//要求结果为字符串且输出到屏幕上//curl_setopt($ch,CURLOPT_HEADER,0);//设置header//curl_setopt($ch,CURLOPT_POST,1);//post提交方式//$datacurl_exec($ch);//运行curl$tmpinfocurl_exec($ch);if(curl_errno($ch)){returncurl_error($ch);}curl_close($ch);return$tmpinfo;}functiongetAccessToken(){//access_token应该全局存储与更新,以下代码以写入到文件中做示例//如果是企业号用以下URL获取access_token//$urlhttps://qyapi.weixin.qq.com/cgibin/gettoken?corpid$thisappIdcorpsecret$thisappSecret;$urlhttps://api.weixin.qq.com/cgibin/token?grant_typeclient_credentialappid$thisappIdsecret$thisappSecret;$resjson_decode($thishttpGet($url));$access_token$resaccess_token;return$access_token;}functionhttpGet($url){$curlcurl_init();curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);curl_setopt($curl,CURLOPT_TIMEOUT,500);curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,true);curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,true);curl_setopt($curl,CURLOPT_URL,$url);$rescurl_exec($curl);curl_close($curl);return$res;}$formid$_GET[formid];$openid$_GET[openid];$address$_GET[address];$goose$_GET[goose];$time$_GET[time];$seats123456789;$templateidtSUGEFLRf69vk1A6Ap1MC1Clhdasu6MekZhMXQe670I;$dataEND{touser:{$openid},template_id:{$templateid},page:logs,form_id:{$formid},data:{keyword1:{value:{$goose},color:173177},keyword2:{value:$address,color:173177},keyword3:{value:$time,color:173177}},emphasis_keyword:keyword1.DATA}END;$appidwxe9252c5efb58fcce;$secret96c39e56274719aa8bf6fbd7c32f96fa;$getTokenApiapi.weixin.qq.com/cgibin/token?grant_typeclient_credentialappid{$appid}secret{$secret};$resultStrhttpGet($getTokenApi);$arrjson_decode($resultStr,true);$token$arr[access_token];$templateApihttps://api.weixin.qq.com/cgibin/message/wxopen/template/send?access_token{$token};$reshttpPost($data,$templateApi);?好几天了,实在不会,求指教谢谢了。
摘要:小程序模板消息运行不报错但手机就是没有消息发过来,为什么
展开:在学模板消息时,获得了openid、formid等,运行不报错,但手机真机上就是没有消息发过来,为什么跪求大神指教,调试好多天了。代码如下://app.jsApp({openid:null,onLaunch:function(){varthatthis;wx.login({success:function(res){wx.request({url:https://pinke.applinzi.com/login.php,//仅为示例,并非真实的接口地址data:{code:res.code},header:{contenttype:application/json//默认值},success:function(res){vardatares.data;varopeniddata.openid;that.openidopenid;}})},});}})//index.js//获取应用实例constappgetApp()Page({data:{},onLoad:function(){//console.log(hahah:+app.openid);},formSubmit:function(e){varopenidapp.openid;varformide.detail.formId;vargoosee.detail.value.goose;varaddresse.detail.value.address;vartimee.detail.value.time;console.log(e);console.log(wosh是formid:+formid);console.log(wosh是GOOSE:+goose);wx.request({url:https://pinke.applinzi.com/moban.php,data:{openid:openid,time:time,address:address,goose:goose,formid:formid},header:{contenttype:application/json//默认值},success:function(res){console.log(res.data)console.log(已经成功回调request)}})}})后台php:?phpfunctionhttpPost($data,$url){$chcurl_init();//初始化curlcurl_setopt($ch,CURLOPT_URL,$url);//抓取指定网页curl_setopt($ch,CURLOPT_CUSTOMREQUEST,POST);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);curl_setopt($ch,CURLOPT_USERAGENT,Mozilla/5.0(compatible;MSIE5.01;windowsNT5.0));curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);curl_setopt($ch,CURLOPT_AUTOREFERER,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$data);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//要求结果为字符串且输出到屏幕上//curl_setopt($ch,CURLOPT_HEADER,0);//设置header//curl_setopt($ch,CURLOPT_POST,1);//post提交方式//$datacurl_exec($ch);//运行curl$tmpinfocurl_exec($ch);if(curl_errno($ch)){returncurl_error($ch);}curl_close($ch);return$tmpinfo;}functiongetAccessToken(){//access_token应该全局存储与更新,以下代码以写入到文件中做示例//如果是企业号用以下URL获取access_token//$urlhttps://qyapi.weixin.qq.com/cgibin/gettoken?corpid$thisappIdcorpsecret$thisappSecret;$urlhttps://api.weixin.qq.com/cgibin/token?grant_typeclient_credentialappid$thisappIdsecret$thisappSecret;$resjson_decode($thishttpGet($url));$access_token$resaccess_token;return$access_token;}functionhttpGet($url){$curlcurl_init();curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);curl_setopt($curl,CURLOPT_TIMEOUT,500);curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,true);curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,true);curl_setopt($curl,CURLOPT_URL,$url);$rescurl_exec($curl);curl_close($curl);return$res;}$formid$_GET[formid];$openid$_GET[openid];$address$_GET[address];$goose$_GET[goose];$time$_GET[time];$seats123456789;$templateidtSUGEFLRf69vk1A6Ap1MC1Clhdasu6MekZhMXQe670I;$dataEND{touser:{$openid},template_id:{$templateid},page:logs,form_id:{$formid},data:{keyword1:{value:{$goose},color:173177},keyword2:{value:$address,color:173177},keyword3:{value:$time,color:173177}},emphasis_keyword:keyword1.DATA}END;$appidwxe9252c5efb58fcce;$secret96c39e56274719aa8bf6fbd7c32f96fa;$getTokenApiapi.weixin.qq.com/cgibin/token?grant_typeclient_credentialappid{$appid}secret{$secret};$resultStrhttpGet($getTokenApi);$arrjson_decode($resultStr,true);$token$arr[access_token];$templateApihttps://api.weixin.qq.com/cgibin/message/wxopen/template/send?access_token{$token};$reshttpPost($data,$templateApi);?好几天了,实在不会,求指教谢谢了。
标签:小程序
「小程序模板消息运行不报错但手机就是没有消息发过来,为什么」热门讨论订阅
方法1:微信扫描微信公开课小程序码即可订阅热门讨论「小程序模板消息运行不报错但手机就是没有消息发过来,为什么」
方法2:微信搜索微信公开课小程序名称进入,即可订阅热门讨论「小程序模板消息运行不报错但手机就是没有消息发过来,为什么」
方法3:微信网页访问即速商店,长按识别微信公开课小程序码即可订阅热门讨论「小程序模板消息运行不报错但手机就是没有消息发过来,为什么」
微信公开课小程序热门讨论「小程序模板消息运行不报错但手机就是没有消息发过来,为什么」由微信公开课原创摘录于微信小程序商店shop.jisuapp.cn,转载请注明出处。
微信公开课热门讨论「小程序模板消息运行不报错但手机就是没有消息发过来,为什么」由微信公开课开发者向微信用户提供,并对本服务内容、数据资料及其运营行为等真实性、合法性及有效性承担全部责任。
微信公开课小程序
更新时间:2019-04-03 15:16:50
>
__methodCallerx27;ofundefined
>-404011cloudfunctionexecutionerror
>,请补充选择商家自营-预付卡销售-发行方类目,并在基础信息处申请该类目,通过
>:host在模拟器中显示无效
>:请在小程序服务页面上架正式(非测试)内容或商品后重新提交审核
>.net 微信小程序 上传图片
>'setTimeout'的问题
>‘三朵里熙SPA主题减压空间’为什么搜索关键词‘三朵里‘搜不到
>‘扫普通链接二维码打开小程序‘中设置为体验版,扫码打开是线上版本
>“cloudfunctions**indexjs”gitignore
>“NO ULINK DEVICE FOUND”是怎么回事
>“万马掌上校园”的类目审核
>“上线了”公司开发的微信小程序怎么样?
>“产品是否一定需要条形码”
>