As the chief Chinese Duan sub-operator of Open Source, Duan Zi Porter must have special techniques for releasing Duan Zi
Duan Zi Porter
After obtaining the latest segment from the egg, log on to the OSC and move it. Database support is not required.
Configuration item
Joke.txtto and cookie.txt files require 777 permissions
You need to know the encrypted password and user_id and user_code of your OSC.
Then with crontab */5 */usr/bin/curl http://jokeporter.fans7.me/JokePorter.php
Check whether a new segment is released every 5 minutes.
Github: https://github.com/wangkugou1983/JokePorter
The next plan is "open source China thumb ups"
Get_joke (); // Obtain the field sub} // Obtain the field sub-private function get_joke () {$ html = file_get_contents ('http: // response); preg_match_all ('/[\ S \ S] *? <\/P>/', $ html, $ res); $ joke = strip_tags ($ res [0] [2]); // Obtain the field $ file = file_get_contents ('. /Joke.txt '); // Local field $ joke! = $ File? $ This-> stash_joke ($ joke): ''; // if the field is newer than the local one, store the field locally} // store the field private function stash_joke ($ joke) {$ handle = fopen ('. /Joke.txt ', "w"); fwrite ($ handle, $ joke); fclose ($ handle); $ this-> login_osc (); // log on to OSC} // log on to OSC private function login_osc () {// log on to $ post = array ('email '=> 'Your OSC email account ', 'pwd' => 'encrypted password', 'SAVE _ login' => '1'); $ curl = curl_init (); // initialize the curl module curl_setopt ($ curl, CURLOPT_URL ,' https://www.oschina.net/action/user/hash_login '); // The submitted login address curl_setopt ($ curl, CURLOPT_HEADER, 0); // whether to display the header information curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 0); curl_setopt ($ curl, CURLOPT_COOKIEJAR ,'. /cookie.txt '); // Set the cookie information to save in the specified file curl_setopt ($ curl, CURLOPT_POST, 1); // submit curl_setopt ($ curl, CURLOPT_POSTFIELDS, http_build_query ($ post); // information to be submitted $ res = curl_exec ($ curl); // execute cURL $ res? $ This-> push_joke ($ curl): curl_close ($ curl);} // publish a segment private function push_joke ($ curl) {$ file = file_get_contents ('. /Joke.txt '); // Local field $ send = array ('MSG' => $ file, 'user' => 'Your user_id ', 'user _ code' => 'Your user_code '); curl_setopt ($ curl, CURLOPT_URL ,' https://www.oschina.net/action/tweet/pub '); Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); // curl_exec returns the result instead of executing curl_setopt ($ curl, CURLOPT_POST, 1 ); // submit curl_setopt ($ curl, CURLOPT_POSTFIELDS, http_build_query ($ send) in post mode; // the information to be submitted curl_exec ($ curl ); // execute cURL curl_close ($ curl) ;}$ JokePorter = new JokePorter (); $ JokePorter-> index ();
The above is the content of the section Porter. For more information, see The PHP Chinese website (www.php1.cn )!