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 ();