2014-04-23 15 views
2

我在Google Plus上找到關於Post的文章 https://developers.google.com/+/api/latest/moments/insert如何將自動發佈到谷歌加PHP?

從那我們找到的例子展示瞭如何創建時刻。

$moment_body = new Google_Moment(); 
$moment_body->setType("http://schemas.google.com/AddActivity"); 
$item_scope = new Google_ItemScope(); 
$item_scope->setId("target-id-1"); 
$item_scope->setType("http://schemas.google.com/AddActivity"); 
$item_scope->setName("The Google+ Platform"); 
$item_scope->setDescription("A page that describes just how awesome Google+ is!"); 
$item_scope->setImage("https://developers.google.com/+/plugins/snippet/examples/thing.png"); 
$moment_body->setTarget($item_scope); 
$momentResult = $plus->moments->insert('me', 'vault', $moment_body); 

從谷歌API客戶端庫PHP我不是找到Google_ItemScope API和Google_Moment是Google_PlusMomentsService.php。所以不能嘗試這個例子。

有人知道嗎?或者有解決方案可以嘗試在谷歌加使用PHP自動發佈?

感謝

+0

'注意事項:使用Google+ API目前提供的公開數據進行只讀訪問。所有API調用都需要OAuth 2.0令牌或API密鑰。「https://developers.google.com/+/api/ – waki

+0

該示例使用舊版本的客戶端庫。嘗試在Google/Service/Plus.php中查找Google_Service_Plus_ItemScope,並以相同的方式使用它(同樣適用於Moment).https://github.com/google/google-api-php-client/blob/master/src/Google /Service/Plus.php#L2077 –

回答

2

我也發現了同樣的問題,在新的谷歌+ API他們改變類名試試下面的代碼

$plusservicemoment = new Google_Service_Plus_Moment(); 
$plusservicemoment->setType("http://schemas.google.com/AddActivity"); 
$plusService = new Google_Service_Plus($client); 

$item_scope = new Google_Service_Plus_ItemScope(); 
$item_scope->setId('12345'); 
$item_scope->setType("http://schemas.google.com/AddActivity"); 
$item_scope->setName("yout site/api name"); 
$item_scope->setDescription("A page that describes just how html work!"); 
//$item_scope->setImage("full image path here"); 
$plusservicemoment->setTarget($item_scope); 
$result = $plusService->moments->insert('me','vault',$plusservicemoment); 
+0

您能否爲我提供此類「Google_Service_Plus_Moment」的鏈接? –

相關問題