卷曲登录并获得会议 [英] login with curl and get session

查看:218
本文介绍了卷曲登录并获得会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我需要以某种方式从

hello i need somehow to get top Regional interest and interest over time from

http://www.google.com/trends?q=lingerie+&ctab=0&geo=id&date=all&sort=0

或更好

http://www.google.com /见解/搜索/#q =内衣及放大器;地理= ID&安培; CMPT = q

让我发现我们必须登录到数据导出任何人可以给我一个例子与我们的谷歌的用户名和密码,这样做呢?也许使用curl导出数据?还是其他什么东西。

so i found out that we have to login to export data can anybody give me an example doing this with our google username and password? maybe using curl to export the data? or something else

感谢您寻找在

亚当斋月

推荐答案

只是要快了,我用我的 xhttp类这是一个卷曲的包装,而且我觉得code是很容易理解。

Just to be quick about it, I used my xhttp class which is a curl wrapper, and I think the code is easy enough to follow.

<?php

header('content-type: text/plain');

// Set account login info
$data['post'] = array(
  'accountType' => 'HOSTED_OR_GOOGLE',  // indicates a Google account
  'Email'       => '',  // full email address
  'Passwd'      => '',
  'service'     => 'trendspro', // Name of the Google service
  'source'      => 'codecri.me-example-1.0' // Application's name, e.g. companyName-applicationName-versionID
);

$response = xhttp::fetch('https://www.google.com/accounts/ClientLogin', $data);

// Test if unsuccessful
if(!$response['successful']) {
    echo 'response: '; print_r($response);
    die();
}

// Extract SID
preg_match('/SID=(.+)/', $response['body'], $matches);
$sid = $matches[1];

// Erase POST variables used on the previous xhttp call
$data = array();

// Set the SID in cookies
$data['cookies'] = array(
    'SID' => $sid
);

$response = xhttp::fetch('http://www.google.com/insights/search/overviewReport?q=lingerie&geo=ID&cmpt=q&content=1&export=1', $data);

// CSV data in the response body
echo $response['body'];

?>

其结果是:的http:// $ C $煤炭科学研究总院.ME /应用/测试/ test.google.trends.php
但我不知道,如果结果是你在找什么。

The result is at: http://codecri.me/apps/test/test.google.trends.php But I'm not sure if the result is what you are looking for.

这篇关于卷曲登录并获得会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆