2012-10-18 28 views
1

美好的一天。通過.NET製作Google Plus(C#)

有沒有人有一個工作示例如何通過.NET(C#)進行Google Plus發佈。

我已經嘗試谷歌和stackoverflow搜索,但沒有設法找到解決方案。

我順利拿到帖子:

public void Post(string text) 
    { 
     PlusService plus = new PlusService {Key = "MYVERYSECRETKEY"}; 

     ActivitiesResource ar = new ActivitiesResource(plus, null); 

     ActivitiesResource.ListRequest list = ar.List("108055870103885325249", new ActivitiesResource.Collection()); 
     ActivityFeed feed = list.Fetch(); 

     string activityKey = ""; 
     foreach (var a in feed.Items) 
      if (a.Url == "https://plus.google.com/108055870103885325249/posts/EtvvUgn8eKz") 
      { 
       activityKey = a.Id; 
       break; 
      } 

     ActivitiesResource.GetRequest get = ar.Get(activityKey); 
     Activity act = get.Fetch(); 
     var sb = new System.Text.StringBuilder(); 
     sb.AppendLine("Title: " + act.Title); 
     sb.AppendLine("URL:" + act.Url); 
     sb.AppendLine("Published:" + act.Published); 
     sb.AppendLine("By:" + act.Actor.DisplayName); 
     sb.AppendLine("Annotation:" + act.Annotation); 
     sb.AppendLine("Content:" + act.Object.Content); 
     sb.AppendLine("Type:" + act.Object.ObjectType); 
     sb.AppendLine("# of +1s:" + act.Object.Plusoners.TotalItems); 
     sb.AppendLine("# of reshares:" + act.Object.Resharers.TotalItems); 
    } 

但我找不到決策職位的任何方法。

在此先感謝。

+2

你見過[這個Google plus平臺頁面](https://developers.google.com/+/downloads/)嗎?它有一個(測試版現在)[.net客戶端](https://code.google.com/p/google-api-dotnet-client/) –

+0

我使用這個庫,但無法找到如何發佈使用它 – user306080

+0

@ user306080:請顯示您到目前爲止所嘗試的內容。 –

回答

6

目前,Google+ API不允許將帖子寫入用戶的活動流。您可以使用moments.insert method in the Google+ REST APIApp Activities寫入用戶的個人資料,用戶可以選擇是公開共享還是共享他們的圈子。

通過發佈到moments.insert端點,您可以以類似於.NET中其他REST API的方式使用REST API。

此功能現在可以說要求https://www.googleapis.com/auth/plus.login範圍和指定的應用程序要在request_visible_actions參數寫無論是在Google+ Sign-In button或直接在OAuth查詢參數type of moments應用。