n3r0x Posted September 23, 2010 Share Posted September 23, 2010 I manage to get the SID= LSID= and Auth= using $url[0] = "https://www.google.com/accounts/ClientLogin"; $url[1] = "http://www.google.com/trends/viz?q=".$keyword."&date=all&geo=all&graph=all_csv&sort=0&sa=N"; $header = array('Connection: keep-alive', 'Keep-Alive: 115', 'Accept: ', 'Accept-Charset: utf-8', 'Accept-Encoding: ', 'Accept-Language: en-us,en', 'Referer: ', 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10' ); $login = "Email={myemail}&Passwd={mypassword}&accountType=GOOGLE&source=CompanyTool-cURL-0.1&service=trends"; // Login $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url[0]); curl_setopt($ch,CURLOPT_HEADER,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$login); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_AUTOREFERER,true); curl_setopt($ch,CURLOPT_HTTPHEADER,$header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $text = curl_exec($ch); print($text); curl_close($ch); but when i try to access $url[1] using: // Auth string i got from previous connction $auth = "XXXXXXXXXXXXXXXXXXXX"; // Add auth to header $header = array('Authorization: GoogleLogin auth='.$auth.''); // Start new curl session $ch = curl_init(); // Set URL curl_setopt($ch,CURLOPT_URL,$url[1]); curl_setopt($ch,CURLOPT_HTTPHEADER,$header); // So that we get the output curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); // Auto referer (not needed but added anyway "jic") curl_setopt($ch,CURLOPT_AUTOREFERER,true); curl_setopt($ch,CURLOPT_HEADER,true); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,false); $text = curl_exec($ch); curl_close($ch); print($text); it says something like: "You must login to download data from google trends" Anyone know what´s wrong or have another way to download csv files from Google trends? Link to comment https://forums.phpfreaks.com/topic/214189-problem-with-clientlogin-and-google-trends/ Share on other sites More sharing options...
n3r0x Posted September 24, 2010 Author Share Posted September 24, 2010 Solved it.. Link to comment https://forums.phpfreaks.com/topic/214189-problem-with-clientlogin-and-google-trends/#findComment-1115027 Share on other sites More sharing options...
ramascaro Posted May 27, 2011 Share Posted May 27, 2011 n3r0x, could you tell us how did you solved it? Could this work with google insights too? Thanks! Link to comment https://forums.phpfreaks.com/topic/214189-problem-with-clientlogin-and-google-trends/#findComment-1221133 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.