4

C#を使用して、このようなGoogle +投稿の共有、コメント、いいねを読みたいhttps://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD

4

1 に答える 1

7

その投稿はアクティビティです。このページには、アクティビティに関する情報を取得する方法に関する情報が含まれています。このページでは、APIの使用例をいくつか示します。このページには、Google API.NETライブラリのダウンロードがあります。これを使用してGoogle+APIにアクセスし、XMLドキュメントなどを使用できます。

APIキーを取得し、APIの使用を管理するには、 APIコンソール を使用する必要があります。

APIExplorerもご覧ください。

実例は次のとおりです。


Google.Apis.dllとGoogle.Apis.Plus.v1.dllを参照する

        PlusService plus = new PlusService();
        plus.Key = "YOURAPIKEYGOESHERE";
        ActivitiesResource ar = new ActivitiesResource(plus);
        ActivitiesResource.Collection collection = new ActivitiesResource.Collection();

        //107... is the poster's id
        ActivitiesResource.ListRequest list = ar.List("107200121064812799857", collection); 
        ActivityFeed feed = list.Fetch();

        //You'll obviously want to use a _much_ better way to get
        // the activity id, but you aren't normally searching for a
        // specific URL like this.
        string activityKey = "";
        foreach (var a in feed.Items)
            if (a.Url == "https://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD")
            {
                activityKey = a.Id;
                break;
            }

        ActivitiesResource.GetRequest get = ar.Get(activityKey);
        Activity act = get.Fetch();
        Console.WriteLine("Title: "+act.Title);
        Console.WriteLine("URL:"+act.Url);
        Console.WriteLine("Published:"+act.Published);
        Console.WriteLine("By:"+act.Actor.DisplayName);
        Console.WriteLine("Annotation:"+act.Annotation);
        Console.WriteLine("Content:"+act.Object.Content);
        Console.WriteLine("Type:"+act.Object.ObjectType);
        Console.WriteLine("# of +1s:"+act.Object.Plusoners.TotalItems);
        Console.WriteLine("# of reshares:"+act.Object.Resharers.TotalItems);

        Console.ReadLine();

出力:

    Title: Wow Awesome creativity...!!!!!
    URL:http://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD
    Published:2012-04-07T05:11:22.000Z
    By:Funny Pictures & Videos
    Annotation:
    Content: Wow Awesome creativity...!!!!!
    Type:note
    # of +1s:210
    # of reshares:158
于 2012-04-07T11:23:11.070 に答える