PHP: log on to oschina and release the chicken soup publisher-PHP source code

Source: Internet
Author: User
PHP: log on to oschina and release php code

 Login (); $ this-> send ();}/*** logon account */private function login () {$ url =" https://www.oschina.net/action/user/hash_login ";/*** Obtain the account and password by yourself */$ data =" email = enter the account here & pwd = enter the password here & verifyCode = & save_login = 1 "; $ curl = curl_init (); // Start a CURL session curl_setopt ($ curl, CURLOPT_URL, $ url); // curl_setopt ($ curl, CURLOPT_SSL_VERIFYPEER, 0 ); // Check the certificate source curl_setopt ($ curl, CURLOPT_SSL_VERIFYHOST, 2); // check from the certificate whether the SSL encryption algorithm has curl_setopt ($ curl, CURLOPT_USERAGENT, $ _ SERVER ['http _ USER_AGENT ']); // simulate the user's browser curl_setopt ($ curl, CURLOPT_FOLLOWLOCATION, 1); // use automatic jump curl_setopt ($ curl, CURLOPT_AUTOREFERER, 1); // automatically sets Referer curl_setopt ($ curl, CURLOPT_POST, 1); // sends a regular Post request curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ data ); // Post the submitted data packet curl_setopt ($ curl, CURLOPT_COOKIEJAR, $ this-> cookie); // The name of the file containing the Cookie information curl_setopt ($ curl, CURLOPT_COOKIEFILE, $ this-> cookie); // read the previously stored Cookie information curl_setopt ($ curl, CURLOPT_TIMEOUT, 30); // Set the timeout limit to prevent endless loops curl_setopt ($ curl, CURLOPT_HEADER, 0); // display the returned Header area content curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); // The obtained information returns curl_exec ($ curl) as a file stream ); // execute curl_close ($ curl); // close CURL session}/*** send chicken soup */private function send () {$ post = $ this-> getChicken (); $ url =" http://my.oschina.net/action/tweet/pub "; $ Data =" user = 2251019 & user_code = Watermark & attachment = 0 & code_brush = & code_snippet = & msg = {$ post ['post _ content']} "; $ curl = curl_init (); // Start a CURL session curl_setopt ($ curl, CURLOPT_URL, $ url); // curl_setopt ($ curl, CURLOPT_POST, 1 ); // send a regular Post request curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ data); // curl_setopt ($ curl, CURLOPT_COOKIEFILE, $ this-> cookie) submitted by Post ); // read the previously stored Cookie information curl_setopt ($ curl, CURLOPT_TIMEOUT, 30); // Set the timeout limit to prevent endless loops curl_setopt ($ curl, CURLOPT_HEADER, 0 ); // display the returned Header content curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); // The obtained information returns $ tmpInfo = curl_exec ($ curl) as a file stream ); // execute curl_close ($ curl); // Close the CURL session $ this-> recordSend ($ post ['post _ id']);} /*** get the latest chicken soup */private function getChicken () {$ Something = $ this-> db-> prepare ("SELECT * FROM {$ this-> prefix} post WHERE post_send = 0 order by post_id asc limit 1 "); $ Something-> execute (); $ result = $ Something-> fetch (); return $ result;}/*** record sending */private function recordSend ($ post_id) {$ Something = $ this-> db-> prepare ("UPDATE {$ this-> prefix} post SET post_send = 1 WHERE post_id =: post_id "); $ Something-> execute (array ('post _ id' => $ post_id) ;}}$ mail = new sendChicken (); $ mail-> index ();

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.