Java invokes a friendly interface to a specified friend push message (ii) post test

Source: Internet
Author: User

Forex API interface is simple to do

Http://open.yixin.im/document/oauth/api

Follow the steps in the guide to take advantage of the test ID provided by the easy-faith

AppID (client_id): yxbbd0e8b3dce64e02bab42437becc4384 appsecret:5a1db5830047b4a

Access_token can be easily obtained, as well as specifying the toaccountid of the contact person

Next, submit a test request to the Forex Web Service using the Apache HTTP component mentioned in the previous blog post

 PackageCom.newflypig.demo;Importjava.util.ArrayList;Importjava.util.List;ImportOrg.apache.http.HttpResponse;ImportOrg.apache.http.NameValuePair;Importorg.apache.http.client.HttpClient;Importorg.apache.http.client.entity.UrlEncodedFormEntity;ImportOrg.apache.http.client.methods.HttpPost;Importorg.apache.http.impl.client.HttpClients;ImportOrg.apache.http.message.BasicNameValuePair;Importorg.apache.http.util.EntityUtils;/*** Example of sending post requests to the e-mail server *@authorNewflydd * The relevant data of the letter of trust is as follows: * URL:https://open.yixin.im/api/sendp2pmsg* access_token:b2421624-db5c-44d1-93f0-1e71f9cxxxxx * TOACCOUNTID:6C0F7514F4BDXXXX (唐蔚) ; Fd60e46db0dc119cfea740c3375xxxxx (Wang Qun) * Content: Data that needs to be pushed * {"text_content": "This text is sent from the easy-Letter SDK sample program, and sent by the server automatic call", "desc": " No description required, "type": "Text"} * {"image": "http://img.hoop8.com/attachments/1510/911826782594.jpg" ," title ":" New Development Points "," url ":"http://img.hoop8.com/attachments/1510/911826782594.jpg"," type ":" Image "} **/ Public classSendposttoyixin { Public Static voidMain (string[] args)throwsexception{HttpClient Client=Httpclients.createdefault (); HttpPost Post=NewHttpPost ("Https://open.yixin.im/api/sendp2pmsg"); List<NameValuePair> parameters=NewArraylist<namevaluepair>(); Parameters.Add (NewBasicnamevaluepair ("Access_token", "b2421624-db5c-44d1-93f0-1e71f9cxxxxx")); Parameters.Add (NewBasicnamevaluepair ("Toaccountid", "fd60e46db0dc119cfea740c337xxxxx")); Parameters.Add (NewBasicnamevaluepair ("content", "{\" text_content\ ": \" This text is sent from the easy-Letter SDK sample program, and sent by the server automatically called \ ", \" desc\ ": \" does not need to describe \ ", \" Type\ " : \ "Text\"} ")); Post.setentity (NewUrlencodedformentity (Parameters, "UTF-8")); HttpResponse Response=Client.execute (POST);    System.out.println (Entityutils.tostring (Response.getentity ())); }}

It's simple, I don't want to explain more.

By the way, bloggers Access_token and Toaccountid the last three letters have been modified, otherwise we can use these two parameters in my name to send a friend message.

After the final success, the following results can be seen in the easy-trust client:

Java invokes a friendly interface to a specified friend push message (ii) post test

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.