PHP thumb ups-PHP source code

Source: Internet
Author: User
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 ();

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.