As an open-source Chinese likes, the PHP likes magic feature must have special likes:
Log on to OSC with an account, obtain the first dynamic attribute on the right of the home page, and click "like". if the first user is clicked, the user will not click again.
Better performance with scheduled tasks
Login_osc (); // login} // log on to the private function login_osc () {$ post = array ('email '=> 'Your mailbox 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 URL curl_setopt ($ curl, CURLOPT_HEADER, 0) submitted for logon ); // whether to display the header information curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 0); curl_setopt ($ curl, CURLOPT_COOKIEJAR ,'. /cookie.txt '); // Set co Okie information is saved in the specified file. curl_setopt ($ curl, CURLOPT_POST, 1); // submit curl_setopt ($ curl, CURLOPT_POSTFIELDS, http_build_query ($ post) in post mode )); // information to be submitted $ res = curl_exec ($ curl); // execute cURL $ res? $ This-> get_data ($ curl): curl_close ($ curl);} // obtain the data private function get_data ($ curl) {curl_setopt ($ curl, CURLOPT_URL, 'http: // www.oschina.net/'); curl_setopt ($ curl, CURLOPT_HEADER, 0); curl_setopt ($ curl, expires, 1); curl_setopt ($ curl, CURLOPT_COOKIEFILE ,'. /cookie.txt '); // read cookie $ html = curl_exec ($ curl ); // execute cURL to capture the page content // get the first dynamic data preg_match ('/[sS] *?
/', $ Html, $ data); // user_code $ user_code = 'Your user_code'; // logid & id $ id = intval ($ data [1]); $ logid = intval ($ data [1]); // ownerOfLogpreg_match ('/href = "http://my.oschina.net /(. *?) "/', $ Data [0], $ user_url); curl_setopt ($ curl, CURLOPT_URL, 'http: // my.oschina.net/'.$user_url1_1]); $ user_html = curl_exec ($ curl ); // execute cURL to capture the page content preg_match ('//', $ User_html, $ ownerOfLog); $ ownerOfLog = intval ($ ownerOfLog [1]); // current_love_count preg_match ('/id = "TopTweets_love _ (w +) _ hidden "value =" (w +) ">/', $ data [0], $ current_love_count); $ current_love_count = intval (trim ($ current_love_count [2]); $ clickCount = intval (0); $ arr = array ('User _ code' => $ user_code, 'logid' => $ logid, 'current _ love_count '=> $ current_love_count, 'id' => $ id, 'clickcount' => $ clickCoun T, 'owneroflog' => $ ownerOfLog); $ user_id = file_get_contents ('./user_id.txt'); // Local User ID $ user_id! = $ OwnerOfLog? $ This-> click ($ arr): ''; // if the local user ID is not the latest user ID of the webpage, click like curl_close ($ curl );} public function click ($ arr) {$ curl = curl_init (); // initialize the curl module curl_setopt ($ curl, CURLOPT_URL ,' http://www.oschina.net/action/tweet/makeAsLove '); // The submitted login address curl_setopt ($ curl, CURLOPT_HEADER, 0); curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ curl, CURLOPT_COOKIEFILE ,'. /cookie.txt '); // read cookie curl_setopt ($ curl, CURLOPT_POST, 1); // submit curl_setopt ($ curl, CURLOPT_POSTFIELDS, http_build_query ($ arr) in post mode )); // curl_exec ($ curl) information to be submitted; // execute cURL // Store User ID $ handle = fopen ('. /user_id.txt ', "w"); fwrite ($ handle, $ arr ['owneroflog']); fclose ($ handle); curl_close ($ curl );}} $ LikeDemon = new LikeDemon (); $ LikeDemon-> index ();