C # implement sending of Feixin text messages

Source: Internet
Author: User

In the first blog, I tried to use C # To send fetion.

2012.09.29 because the verification code is added to this method, you need to bypass it... So, it hurts ..

    • Implementation Principle

Refer to a blog article: Use PHP to simulate logon to WAP to send Apsara stack. Address: http://blog.quanhz.com/archives/118. This section describes in detail how to use the simulated WAP method to implement functions such as login, sending, and logout of Apsara stack. Based on the post and get links it finds, and using the C # httpwebrequest and httpwebresponse classes, you can easily implement a client that can send Apsara.

    • Log on to Apsara stack (CodeFor more information, see comments)
 1           Public   Static String login (string mstr, string pwdstr)
2 {
3 // Field to be post: Where, mstr is the mobile phone number, pwdstr is the password, loginstatus is the login status
4 String ARGs = " M = " + Mstr + " & Pass = " + Pwdstr + " & Amp; loginstatus = 4 " ;
5 Httpwebrequest request = (httpwebrequest) webrequest. Create ( " Http://f.10086.cn/im/login/inputpasssubmit1.action " );
6 Httpwebresponse response = Null ;
7 Encoding encoding = system. Text. encoding. utf8;
8 Byte [] Argsbytes = encoding. getbytes (ARGs ); // Encoding conversion, UTF-8
9 Request. Accept = " Text/html, application/XHTML + XML, application/XML; q = 0.9, */*; q = 0.8 " ;
10 Request. contenttype = " Application/X-WWW-form-urlencoded " ;
11 Request. method = " Post " ; // Set the HTTP Request Method to post
12 Request. Timeout = 1000 ;
13 Request. cookiecontainer = cc; // The key to subsequent operations is to save cookies. Cc = new cookiecontainer () is a static member variable in the class I implemented;
14
15 Stream outstream = request. getrequeststream ();
16 Outstream. Write (argsbytes, 0 , Argsbytes. Length );
17 Response = (httpwebresponse) request. getresponse ();
18 String resultstr = streamtostring (response. getresponsestream ()); // Switch from the returned response stream to string
19 Outstream. Close ();
20
21 Return Resultstr;
22 }
 
    • Send a letter to yourself
 1           Public   Static String sendmsg (string msgstr)
2 {
3 String MSG = " MSG = " + Msgstr; // Msgstr indicates the sent content.
4 Httpwebrequest request = (httpwebrequest) webrequest. Create ( " Http://f.10086.cn/im/user/sendMsgToMyselfs.action " );
5 Httpwebresponse response = Null ;
6 Encoding encoding = system. Text. encoding. utf8; // Be sure to use UTF-8 Encoding
7 Byte [] Argsbytes = encoding. getbytes (MSG );
8 Request. Accept = " */* " ;
9 Request. Timeout = 1000 ;
10 Request. contenttype = " Application/X-WWW-form-urlencoded " ;
11 Request. method = " Post " ;
12 Request. cookiecontainer = cc;
13 Stream outstream = request. getrequeststream ();
14 Outstream. Write (argsbytes, 0 , Argsbytes. Length );
15 Response = (httpwebresponse) request. getresponse ();
16 String resultstr = streamtostring (response. getresponsestream ());
17 Outstream. Close ();
18
19 Return Resultstr;
20 }

After login, sending a mail is a simple implementation process. You only need to post the text message content to a specific URL address. Note: Chinese encoding and cookie problems.

    • Summary

By simulating HTTP, the login and sending functions of Apsara Stack are implemented. By capturing and analyzing 3G Apsara stack data, you can achieve many functions, such as obtaining weather conditions, send to Feixin friends; for example, implement remote shutdown and other applications; for example, the principle of the client of the zhongda educational administration system that I implemented a while ago is similar to this. The two are combined, then, you can use fetion to notify students of the score as soon as the score is published.

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.