1

我正在尝试让这个http://www.forgottenexpanse.com/projects/ci_reader CodeIgniter 库与 Google Reader 交互工作。

遵循页面上的示例时,这可以正常工作:

$this->load->library('reader');
$shared_items = $this->reader->shared_items('12006118737470781753');

foreach ($shared_items['items'] as $entry) {
    echo $entry['title'];
}

但是当试图通过登录来获取非公开数据时:

$this->load->library('reader');
$credentials = array('email' => 'me@gmail.com', 'password' => 'mypassword');
$this->reader->initialize($credentials);

$shared_items = $this->reader->shared_items();
foreach ($shared_items['items'] as $entry) {
    echo $entry['title'];
}

我收到一堆与 library/Reader.php 的第 454 行相关的警告,例如:

消息:simplexml_load_string():实体:第 128 行:解析器错误:StartTag:无效元素名称

我希望有人知道这里可能会发生什么。

非常感谢!

4

1 回答 1

2

您指向的库仍使用 SID cookie 向 Reader 进行身份验证。这在几个月前已被弃用。新的首选身份验证方案是 OAuth 或带有身份验证令牌的 ClientLogin;两者都在http://code.google.com/p/google-reader-api/wiki/Authentication中进行了描述。

在这种特殊情况下,您必须修改_login函数以从响应中获取Auth令牌。ClientLogin拥有它后,您还需要修改_fetch函数以将其作为Authorization标头包含(而不是添加 cookie)。

于 2010-10-24T15:47:45.070 回答