(Download the latest version: code. google. compphp-fetiondownloadsdetail? Namephpfetion_v1.3.0.zip) It has been reported by some netizens recently that the PHPFetion class cannot send emails to friends, but you can still send emails to yourself. Through prompts from netizens and my own research, I found that a csrf was added to send messages to friends in wap mail.
(Latest Version Download: http://code.google.com/p/php-fetion/downloads/detail? Name‑phpfetion_v1.3.0.zip) Some netizens have recently reported that the PHPFetion class cannot send emails to friends, but you can still send emails to yourself. Through prompts from netizens and my own research, I found that a csrf was added to send messages to friends in wap mail.
(Latest Version Download: http://code.google.com/p/php-fetion/downloads/detail? Name1_phpfetion_v1.3.0.zip)
Recently, some netizens have reported that the PHPFetion class cannot send emails to friends, but it can also be sent to itself. Through prompts from netizens and my own research, I found that a csrfToken field was added when I sent messages to friends in wap mail.
Unexpectedly, this csrfToken should be used to prevent form cross-site submission. However, because the csrfToken plain text appears in the form page for sending a mail to friends, it is easy to get it. In addition, this csrfToken remains unchanged when sending emails to any other friends, so you only need to obtain it once.
I wrote the following code to obtain the csrfToken:
/*** CsrfToken * @ param string */protected $ _ csrfToten = null;/*** get csrfToken, this field * @ param string $ uid Feixin ID * @ return string */protected function _ getCsrfToken ($ uid) is required when sending a mail to friends) {if ($ this-> _ csrfToten = null) {$ uri = '/im/chat/toinputMsg. action? Touserid = '. $ uid; $ result = $ this-> _ postWithCookie ($ uri, ''); preg_match ('/name =" csrfToken ".*? Value = "(.*?) "/', $ Result, $ matches); $ this-> _ csrfToten = isset ($ matches [1])? $ Matches [1]: '';} return $ this-> _ csrfToten ;}
In addition, the _ toUid () function sent to friends is modified:
/*** Send a fetion to a friend * @ param string $ uid fetion ID * @ param string $ message text message content * @ return string */protected function _ toUid ($ uid, $ message) {$ uri = '/im/chat/sendMsg. action? Touserid = '. $ uid; $ csrfToken = $ this-> _ getCsrfToken ($ uid); $ data = 'msg = '. urlencode ($ message ). '& csrfToken = '. $ csrfToken; $ result = $ this-> _ postWithCookie ($ uri, $ data); return $ result ;}
The written Code is still in Google Code and packaged into PHPFetion v1.3, Which is http://code.google.com/p/php-fetion/downloads/list.
Original article address: I would like to thank the original author for sharing my question about PHPFetion's failure to send a flying letter to friends.