【问题标题】:Google Plus PHP api - Insert Moments not workingGoogle Plus PHP api - 插入时刻不起作用
【发布时间】:2013-04-14 13:56:41
【问题描述】:

我想将我的状态分享给 google plus。

我遵循了 google api,但我收到了未经授权的错误。我试图修复它超过 2 天,但我不能..

我阅读了这个答案,我下载并测试了 api,但仍然不适合我。

401 Unauthorized access when posting Google+ Moments with PHP Client

你可以在这里查看,

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

在这个主干文件中,他们仍然在调用 Google_PlusMomentsService.php

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

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

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

 $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 google-plus google-api-php-client


    【解决方案1】:

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

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

    这是最新的 PHP 启动器,已经过验证可以工作。如果您真的非常想使用您分享的旧代码,请分享登录按钮标记,例如:

    <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...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多