Post Moments with Wechat API on Android

2019-06-04 04:25发布

问题:

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.

Here is my code:

  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 : Wechat didn't approve the app yet (submitted it 1 month ago). Could it be one of the reason?

回答1:

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

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).

Solution :

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.

I got my application approved after 3 business days.



回答2:

After Searching a lot finally got answer as Eric suggest login to weixin.qq.com site

here you need to submit 2 things, application package name and signature, signature is not any sha1 or md 5

download we chat apk from this link and generate signature from this apk, and submit on site.

https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419319167&token=&lang=zh_CN