Using PHP to login WAP fetion implementation fetion send _php Tutorial

Source: Internet
Author: User
There are many third-party fetion interfaces available on the Internet. The disadvantage is not too stable, many to now fail to use, in addition we will worry about the leakage of information. In fact, we can do a self-implementation of an interface like this, I give the idea is very simple: through the simulation of the WAP version fetion, to achieve fetion and other operations. The choice of WAP fetion is mainly due to its simple interface, easy analysis and no verification code.

1. Install the Firefox plugin wmlbrowser

This allows us to browse WAP pages directly with Firefox and can also use Firebug to analyze the interface. Download Address: https://addons.mozilla.org/zh-CN/firefox/search/?q=wmlbrowser&cat=all&x=17&y=11

2. Analysis of the login page

WAP Fetion entry for http://f.10086.cn/, click on "Chat WAP fetion" To enter the login page (http://f.10086.cn/im/login/login.action). By Firebug, you can see:

A total of 3 fields: Pass (password), loginstatus (login status), M (mobile number)
Submitted to the Action:http://f.10086.cn/im/login/inputpasssubmit1.action

Actually get the field of form submission, here is a trickery way: modify the action, let it point to its own program, such as:

I changed the action to a local PHP program, this program is just a simple sentence print_r ($_post), the results are:

These are the data that the form will submit.

3. Use Curl to implement a simulated login operation

From the above analysis, the content submitted at login is relatively simple, there is no verification code, there is no cross-domain commit hash value verification. Then we use the Curl simulation to submit this login form. In fact, it sends a post-mode HTTP request, and curl can save the returned cookie as a file. This cookie file will be used for subsequent operations such as sending Fetion.

The code is as follows:

$cookie = DirName (__file__). ' /cookie.txt '; $post = Array (        ' m ' = = ' 13700001234 ',        ' pass ' = ' 123456 ',        ' loginstatus ' = = 1,); $curl = Curl_init (' http://f.10086.cn/im/login/inputpasssubmit1.action '); curl_setopt ($curl, Curlopt_header, 0); Curl_ Setopt ($curl, Curlopt_returntransfer, 1); curl_setopt ($curl, Curlopt_cookiejar, $cookie); Watch this! Save Cookiecurl_setopt ($curl, Curlopt_post, 1); curl_setopt ($curl, Curlopt_postfields, Http_build_query ($post)); $ result = Curl_exec ($curl); Curl_close ($curl);

If the login is successful, you can determine the value of $result.

4. Carry a cookie to send yourself fetion

It is relatively simple to send a fetion to a friend, there is a special page. You can go to the "home page from the login" and "Send yourself a text message" To enter the address:
Http://f.10086.cn/im/user/sendMsgToMyself.action.

Analyze the form in the same way as above:

Only one field: Msg (SMS content)
Submitted to the Action:http://f.10086.cn/im/user/sendmsgtomyselfs.action

Use Curl to send a post-mode request to this URL, plus the cookie you saved above, and here's the code:

$post = Array (        ' msg ' = ' Hello fetion ',); $curl = Curl_init (' http://f.10086.cn/im/user/sendMsgToMyselfs.action ') ); curl_setopt ($curl, Curlopt_header, 0); curl_setopt ($curl, Curlopt_returntransfer, 1); curl_setopt ($curl, Curlopt_ Cookiefile, $cookie);        Watch this! curl_setopt ($curl, Curlopt_post, 1); curl_setopt ($curl, Curlopt_postfields, Http_build_query ($post)); $result = Curl_ EXEC ($curl); Curl_close ($curl);

Depending on the returned $result, you can determine whether the send was successful.

5. Get the UserID for your friend's phone number before sending fetion to your friend

Because the form that sends Fetion to a friend is a userid instead of a cell phone number (the analysis of this form is in the next step), we must find a way to figure out the UserID for the phone number. I use the "Search Friends" feature here, on the home page after fetion login, such as:

Search by phone number can get a unique and accurate result, and then we use the regular to match the userid in the result page.

First Analyze This form:

Fields Sent: SearchText (only one)
Submitted to the Action:http://f.10086.cn/im/index/searchotherinfolist.action

Send the request with the Curl simulation code as follows:

$post = Array (        ' searchtext ' = ' 18700008888 ',); $curl = Curl_init (' http://f.10086.cn/im/index/ Searchotherinfolist.action '); curl_setopt ($curl, Curlopt_header, 0); curl_setopt ($curl, Curlopt_returntransfer, 1); curl_setopt ($curl, Curlopt_cookiefile, $cookie);        Watch this! curl_setopt ($curl, Curlopt_post, 1); curl_setopt ($curl, Curlopt_postfields, Http_build_query ($post)); $result = Curl_ EXEC ($curl); Curl_close ($curl);

Get the UserID in the result with a regular:

Preg_match ('/toinputmsg\.action\?touserid= (\d+)/si ', $result, $matches); $userid = Isset ($matches [1])? $matches [1]: ";

This block can be a hint when the userid is not found.

6. Send Fetion to your friends

To the friend Hair Fetion interface, can casually point a friend to enter. Form HTML such as:

Analyze This form:

Fields submitted: Backurl, Touchtitle, Touchtextlength, MSG
Action:http://f.10086.cn/im/chat/sendmsg.action?touserid= the UserID obtained above

The code is as follows:

$post = Array (        ' msg ' = = ' Hello fetion ',); $curl = Curl_init (' http://f.10086.cn/im/chat/sendMsg.action?touserid= '. $userid);         Watch this! curl_setopt ($curl, Curlopt_header, 0); curl_setopt ($curl, Curlopt_returntransfer, 1); curl_setopt ($curl, Curlopt_ Cookiefile, $cookie);        Watch this! curl_setopt ($curl, Curlopt_post, 1); curl_setopt ($curl, Curlopt_postfields, Http_build_query ($post)); $result = Curl_ EXEC ($curl); Curl_close ($curl);

The above $post contains only one field, because I found that the other fields were not required during the experiment. You can determine the success of a send based on the $result returned.

7. Exit Fetion

If you do not quit, then after the login for a short period of time if someone to send you a fetion, it can only be viewed on the WAP fetion, and not automatically sent to your phone. The exit operation is simple and only sends a request for a GET method. The "Exit" link can be seen in the bottom right corner of the home page after login,

The code is as follows:

$curl = Curl_init (' http://f.10086.cn/im/index/logoutsubmit.action '); curl_setopt ($curl, Curlopt_header, 0); Curl_ Setopt ($curl, Curlopt_returntransfer, 1); curl_setopt ($curl, Curlopt_cookiefile, $cookie);        Watch this! $result = curl_exec ($curl); Curl_close ($curl);

8. Summary

Through the above code collation, you can make a fetion send class. It can also be made into a fetion-sent service, such as an interface for easy-to-use HTTP mode. The biggest benefit of fetion is that it is free and can send information to the phone in real time, and can do something like timed SMS or monitoring reminders.

I have encapsulated this as a PHP fetion class.

Click to download:phpfetion v1.2.0 Analog login wap fetion send SMS

http://www.bkjia.com/PHPjc/364736.html www.bkjia.com true http://www.bkjia.com/PHPjc/364736.html techarticle There are many third-party fetion interfaces available on the Internet. The disadvantage is not too stable, many to now fail to use, in addition we will worry about the leakage of information. In fact, we can ourselves ...

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