2013-04-14 25 views
1

我想分享我的地位谷歌加。谷歌加PHP api - 插入時刻不起作用

我跟着谷歌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

這裏是live鏈接whic H I正在測試: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>'; 

任何人都可以修復它吧。

感謝所有

回答

3

您必須授權在PHP客戶端的用戶,並要求可見動作(例如AddActivity)之前,您可以編寫應用程序的活動用戶的個人資料。由於您使用的是較舊的示例,因此您可能不會在按鈕或OAuth2流中設置requestvisibleaction。

嘗試從這裏開始: 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> 

因爲我猜你錯過了行:數據requestvisibleactions ...