我需要从流中获取谷歌+帖子并在我的网站上发布.我知道谷歌没有api这样做.但是像suck http://www.friendsplus.me/这样的服务可以做到这一点.有人知道吗?
首先,您应该去google apis并启用Google Plus服务.它来了;
您可以使用以下代码来读取流帖;
<?php
$google_plus_id = '106670447018211124292';
$appKey = 'app_key_here';
$streams = json_decode(file_get_contents('https://www.googleapis.com/plus/v1/people/' . $google_plus_id . '/activities/public?key='. $appKey));
foreach ($streams->items as $item) {
echo $item->title .
date('F jS Y @ H:i:s',strtotime($item->published)) .
$item->object->content .
'<br />';
}
Run Code Online (Sandbox Code Playgroud)
您还可以在google api控制台上测试此代码的工作.
1.)转到API控制台并选择Google+ API
2.)在左侧菜单中选择API菜单
3.)单击该页面上的public.activities.list

4.)在userId部分输入您的个人资料ID,然后在收集部分输入"public",然后单击" 执行".你可以在下面看到;

| 归档时间: |
|
| 查看次数: |
3940 次 |
| 最近记录: |