Google Plus PHP API-插入时刻不起作用 [英] Google Plus PHP api - Insert Moments not working

查看:58
本文介绍了Google Plus PHP API-插入时刻不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将自己的状态分享给google plus.

I want to share my status to google plus.

我关注了google api,但遇到了未经授权的错误.我试图将其修复超过2天,但我无法..

I followed the google api, but i am getting the unauthorized error. I am trying to fix it for more then 2 days, but i could't..

我阅读了此答案,我下载并测试了该api,但仍然对我不起作用.

i read this answer, i download and test the api, still not working for me.

401使用PHP发布Google+ Moments时未经授权的访问客户

您可以在这里查看,

https ://code.google.com/p/google-api-php-client/source/browse/trunk/examples/moments/simple.php

在此中继文件中,他们仍然在调用Google_PlusMomentsService.php

In this trunk file, still they are calling the Google_PlusMomentsService.php

我尝试了以下代码,但仍然无法使用- https://developers.google.com/+/api/latest/moments/insert

i tried the following code, but still not works - https://developers.google.com/+/api/latest/moments/insert

这是我正在测试的实时链接: http://webscarlets.in /projects/babblesuite/gplus/index.php

here is the live link which i am testing: http://webscarlets.in/projects/babblesuite/gplus/index.php

这是我用来分享状态的代码

this is code i am using to share the status

 $target = new Google_ItemScope();
 $target->url = 'https://developers.google.com/+/plugins/snippet/examples/thing';


  $moment = new Google_Moment();
  $moment->type = "http://schemas.google.com/AddActivity";
  $moment->target = $target;

  // Execute the request
  $moments->moments->insert('me', 'vault', $moment);
  print '<p>Created an AddActivity moment</p>';

任何人都可以修复它.

感谢所有人

推荐答案

您需要在PHP客户端中授权用户并请求可见的操作(例如AddActivity),然后才能将应用程序活动写入用户的个人资料.因为您使用的是较旧的示例,所以您可能没有在按钮或OAuth2流中设置requestvisibleactions.

You need to authorize the user in the PHP client and request visible actions (e.g. AddActivity) before you can write app activities to a user's profile. Because you're using the older sample, you probably aren't setting requestvisibleactions either in the button or in your OAuth2 flow.

尝试从这里开始: https://developers.google.com/+/quickstart/php

这是最新的PHP入门程序,已通过验证可以正常工作.如果您确实要使用您共享的旧代码,请共享登录按钮标记,例如:

This is the latest PHP starter and has been verified to work. If you really, really, want to use the older code you've shared, please share the sign-in button markup, e.g.:

<span id="signinButton">
  <span
    class="g-signin"
    data-callback="signinCallback"
    data-clientid="CLIENT_ID"
    data-cookiepolicy="single_host_origin"
    data-requestvisibleactions="http://schemas.google.com/AddActivity"
    data-scope="https://www.googleapis.com/auth/plus.login">
  </span>
</span>

因为我猜你错过了这一行:data-requestvisibleactions ...

Because I'm guessing you're missing the line: data-requestvisibleactions...

这篇关于Google Plus PHP API-插入时刻不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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