Recently has been calling the micro-letter API, but found that the call has been unsuccessful, tangled up for a long time, all aspects of finding tutorials, find the official, the official documents are only very vague, said to be three steps away.
1. Apply for app_id
2, fill in the package name 3,
Gets the MD5 value of the program signature,
These three steps as long as you go right can be transferred, but people do not know that sometimes we pack the KeyStore and our packaged KeyStore get the program signed MD5 is not the same. The program signature value we filled out at the time of the application was formally packaged, but we deployed it in eclipse with our default debug.keystore. The result is that the program signature is not the same, will always be transferred. We don't even know where we're wrong.
First to say how to deploy micro-letter website under the demo bar: "The following quoted content for micro-letter official website"
Micro-letter to the Android API call is a rigorous three verification, only app_id package name and program signature is completely right in the case to be able to pass.
How to run Sdkdemo project
1, Decompression SDK Demo Project compression package, and import to workspace, the following figure:
2, select the Eclipse top menu window->preferences, in the pop-up dialog box, select the Android directory build, as shown below:
The path to specify the custom Debugkeystore option is the Debug.keystore file in the SDK Demo engineering directory, as shown in the following figure:
and apply the configuration.
3, the operation of the Sdk_sample project.
OK, according to the above three steps, you can go through the micro-letter demo, now to see our own demo
1, custom Debugkeystore: Replaced by our own KeyStore
2, put on our application to the mobile phone, and then to the micro-letter website Download a Get program signature MD5 value APK input package name:
3, to micro-letter background application for our debugging application:
Then write the code in the sample code:
Copy Code code as follows:
Private Button Btn_share;
public static final String wx_app_id = "Wxc85b9dbef61b3fe4";
Private IWXAPI API;
Private String text= "Testssss";
@Override
public void OnCreate (bundlesavedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
Btn_share = (Button) Findviewbyid (R.id.btn_share);
API = Wxapifactory.createwxapi (this, wx_app_id,false);
Btn_share.setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View v) {
Api.registerapp (wx_app_id);
Initializes a Wxtextobject object
Wxtextobjecttextobj = Newwxtextobject ();
Textobj.text = text;
Initializes a Wxmediamessage object with the Wxtextobject object
Wxmediamessagemsg = Newwxmediamessage ();
Msg.mediaobject = Textobj;
The title field does not work when you send a text type message
Msg.title = "would be ignored";
Msg.description = "SDDDD";
Construct a req
Sendmessagetowx.reqreq = Newsendmessagetowx.req ();
Req.transaction = buildtransaction ("text"); The transaction field is used to uniquely identify a request
Req.message = msg;
Req.scene = SendMessageToWX.Req.WXSceneTimeline;
Call API interface to send data to micro-mail
Api.sendreq (req);
Finish ();
}
});
}
Private stringbuildtransaction (finalstring type) {
return (type = null)? String.valueof (System.currenttimemillis ())
: Type + system.currenttimemillis ();
}
So far, done. Never forget that your program is packaged with Keysotre and then packaged with that micro-mail program to obtain signatures that are not the same as the signatures you obtain in the Eclpise program deployment. We can apply for a formal application, fill in the information can be exactly the same, but just get rid of
And your app_id.
Micro-Credit Acquisition Program signature tool download address: Http://xiazai.jb51.net/201211/tools/gen_signature_jb51.rar
I don't know if everyone has a look. If you have any more questions, you can add me. Hopefully this article will help the Android code farmers who are using the micro-mail API.