微信获取scheme码提示invalid weapp pagepath rid: 6397ef44-0f537d77-76155114

        今天给定制的企业查一个功能问题,发现后台打印了

 这个错误信息,找前端一起协助排查了下,现将可能导致此问题的原因罗列一下:

1.pagepath配置的路径不对,其中包括,路径不存在,路径不对(比如最前面加了"/")

2.小程序只提交审核但没有发布。

我这边遇到的是第二种,希望能帮助到大家。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的 Java 代示例,用于在微信小程序中获取 scheme : ```java import java.util.HashMap; import java.util.Map; import com.alibaba.fastjson.JSON; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; public class WeChatMiniProgram { private static final String APP_ID = "你的小程序AppID"; private static final String APP_SECRET = "你的小程序AppSecret"; private static final String API_BASE_URL = "https://api.weixin.qq.com"; /** * 获取微信小程序的 accessToken * * @return accessToken * @throws Exception */ public String getAccessToken() throws Exception { OkHttpClient client = new OkHttpClient().newBuilder().build(); String url = API_BASE_URL + "/cgi-bin/token?grant_type=client_credential&appid=" + APP_ID + "&secret=" + APP_SECRET; Request request = new Request.Builder().url(url).method("GET", null).build(); Response response = client.newCall(request).execute(); String responseBody = response.body().string(); Map<String, Object> resultMap = JSON.parseObject(responseBody, HashMap.class); return (String) resultMap.get("access_token"); } /** * 获取微信小程序的 scheme * * @param accessToken * @param pagePath * @return scheme * @throws Exception */ public String getScheme(String accessToken, String pagePath) throws Exception { OkHttpClient client = new OkHttpClient().newBuilder().build(); String url = API_BASE_URL + "/wxa/generatescheme?access_token=" + accessToken; MediaType mediaType = MediaType.parse("application/json"); Map<String, Object> requestBody = new HashMap<>(); requestBody.put("is_expire", false); requestBody.put("jump_wxa", new HashMap<String, Object>() {{ put("path", pagePath); put("query", ""); }}); RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(requestBody)); Request request = new Request.Builder().url(url).method("POST", body).build(); Response response = client.newCall(request).execute(); String responseBody = response.body().string(); Map<String, Object> resultMap = JSON.parseObject(responseBody, HashMap.class); return (String) resultMap.get("scheme"); } public static void main(String[] args) throws Exception { WeChatMiniProgram weChatMiniProgram = new WeChatMiniProgram(); String accessToken = weChatMiniProgram.getAccessToken(); String pagePath = "pages/index/index"; // 小程序页面路径 String scheme = weChatMiniProgram.getScheme(accessToken, pagePath); System.out.println("scheme: " + scheme); } } ``` 其中,`getAccessToken()` 方法用于获取小程序的 access_token,`getScheme()` 方法用于获取小程序的 scheme 。在 `main()` 方法中,你可以使用 `getScheme()` 方法获取指定页面的 scheme ,然后在你的小程序中使用该 scheme
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值