Curl Collection of micro-blog information (analog login Sina Weibo) __ Collection

Source: Internet
Author: User

realize the effect of landing micro-blog and collect micro-blog information

Effect Display:



This is a few days to get a message from Sina Weibo @ me, without a third party login, so only through the analog login to obtain information, the study of the discovery of direct analog login microblogging is more difficult to verify the algorithm is more complex, so the bypass through the login Sina pass to get a cookie to obtain information, the code is as follows.

<?php header (' Content-type:text/html;charset=utf-8 ');

Microblogging login Address $loginUrl = ' https://login.sina.com.cn/sso/login.php?client=ssologin.js (v1.4.15) &_=1403138799543 '; Create a cookie directory under the current file and the corresponding TXT file $cookie _file1 = dirname (__file__). '
/cookie/cookie1.txt '; $cookie _file2 = dirname (__file__). '
/cookie/cookie2.txt '; $cookie _file3 = dirname (__file__). '

/cookie/cookie3.txt ';
$u = ' Weibo username ';

$p = ' micro-blog password ';
$username = Base64_encode ($u);

$password = $p;
Login to Sina passport $loginData [' entry '] = ' SSO ';
$loginData [' gateway '] = ' 1 ';
$loginData [' from '] = ' null ';
$loginData [' savestate '] = ' 30 ';
$loginData [' useticket '] = ' 0 ';
$loginData [' pagerefer '] = ';
$loginData [' vsnf '] = ' 1 ';
$loginData [' su '] = Base64_encode ($u);
$loginData [' service '] = ' SSO ';
$loginData [' sp '] = $password;
$loginData [' sr '] = ' 1920*1080 ';
$loginData [' encoding '] = ' UTF-8 ';
$loginData [' cdult '] = ' 3 ';
$loginData [' domain '] = ' sina.com.cn ';
$loginData [' prelt '] = ' 0 ';

$loginData [' returntype '] = ' TEXT '; $login = Json_decode (Loginpost ($LOGINURL, $loginData), true);

Var_dump ($login);
Get the microblogging cookie $ch = Curl_init ();    
curl_setopt ($ch, Curlopt_url, $login [' crossdomainurllist '][0]);
curl_setopt ($ch, Curlopt_ssl_verifypeer, 0);
curl_setopt ($ch, Curlopt_ssl_verifyhost, 2);
curl_setopt ($ch, curlopt_header,0);    
curl_setopt ($ch, curlopt_returntransfer,1);    
curl_setopt ($ch, Curlopt_cookiefile, $cookie _file1);    
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file2);
$return = curl_exec ($ch);

Curl_close ($ch);
Login to Weibo by getting cookies, auto jump $ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://weibo.com/5589516034/profile?topnav=1&wvr=6&is_all=1");    
curl_setopt ($ch, Curlopt_returntransfer, 1);    
curl_setopt ($ch, Curlopt_cookiefile, $cookie _file2);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file3);    
curl_setopt ($ch, curlopt_followlocation, 1);
$return = curl_exec ($ch);
$info = Curl_getinfo ($ch);

Curl_close ($ch);


Echo $return;
        function Loginpost ($url, $data) {global $cookie _file1; Echo $cookie _fiLe; exit;
        $ch = Curl_init ();    
        curl_setopt ($ch, Curlopt_url, $url);    
        curl_setopt ($ch, curlopt_returntransfer,1);
        curl_setopt ($ch, Curlopt_ssl_verifypeer, false);        
        curl_setopt ($ch, Curlopt_ssl_verifyhost, false);
        curl_setopt ($ch, curlopt_post,1);
        curl_setopt ($ch, Curlopt_postfields, Http_build_query ($data));
        curl_setopt ($ch, Curlopt_cookiejar, $cookie _file1);
        $return = curl_exec ($ch);
        $info = Curl_getinfo ($ch);
        Curl_close ($ch);

return $return; }?>


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.