在 Android 上使用微信 API 发布精彩瞬间 [英] Post Moments with Wechat API on Android

查看:16
本文介绍了在 Android 上使用微信 API 发布精彩瞬间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用微信 API 创建了一个应用程序.我尝试在我的用户的墙上发帖.我可以在iOS上成功发布微信朋友圈(通知说应用程序尚未批准).但是在 Android 上,什么也没有发生.

I created an app with the Wechat API. I try to post on my user's wall. I can publish on Wechat moments successfully on iOS (with the notice saying the app was not approved yet). However on Android, nothing happened.

这是我的代码:

  private IWXAPI api;

  api = WXAPIFactory.createWXAPI(this, Constants.WECHAT_APP_ID);
  api.registerApp(Constants.WECHAT_APP_ID);

  String text = "Post on Wechat Wall";
  WXTextObject textObj = new WXTextObject();
  textObj.text = text;

  WXMediaMessage msg = new WXMediaMessage();
  msg.mediaObject = textObj;
  msg.description = text;
  boolean isChecked = false; // true

  SendMessageToWX.Req req = new SendMessageToWX.Req();
  req.transaction = buildTransaction("text"); 
  req.message = msg;
  req.scene = isChecked ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;

  api.sendReq(req);
  finish();

ps : 微信还没有批准该应用程序(1 个月前提交).这可能是原因之一吗?

ps : Wechat didn't approve the app yet (submitted it 1 month ago). Could it be one of the reason?

推荐答案

问题不是我的代码,而是我提交的平台.

The problem wasn't my code, but the platform where I submitted it.

我提交给dev.wechat.com(英文版的开发者平台),即使文档看起来/最新,iOS 和 Android 的 SDK 不是.并且您提交的内容将永远不会被审核(提交 5 个月后仍然没有任何活动迹象).

I submitted to dev.wechat.com (english version of the developer platform), even if the docs looks/ up to date, the SDK for iOS and Android are not. And your submission will never be reviewed (5 months after the submissions still no sign of activity).

解决方案:

在开发者平台中文版(open.weixin.qq.com)上创建账号, 然后在上面提交您的应用程序.它的字段和顺序与英文平台完全相同.Google 翻译将成为您最好的朋友.

Create an account on the Chinese version of the developer platform (open.weixin.qq.com, then submit your app on it. It's exactly the same fields and order as the english platform. Google translate will be your best friend here.

我的申请在 3 个工作日后获得批准.

I got my application approved after 3 business days.

这篇关于在 Android 上使用微信 API 发布精彩瞬间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆