如何获取谷歌加的post数据(喜欢 - 股 - 留言)? [英] How to get Google Plus's post data ( likes - shares - comments )?

查看:94
本文介绍了如何获取谷歌加的post数据(喜欢 - 股 - 留言)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#,我想读分享,评论和喜欢谷歌+的发布像这样的 https://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD

Using C# , I want to read the Shares , Comments and Likes of a Google + post like this https://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD

推荐答案

这是后一项活动。 本页面包括如何获取有关活动的信息来源信息来源。 此页面提供了使用API​​的一些例子。 此页面先后为谷歌API的下载。 NET库,它可以用来访问了Google+的API,与XML文档等。


您需要使用 API控制台,以获得API密钥和管理您的API使用。


另外看看在 API浏览器


这里有一个工作的例子:

That post is an activity. This page includes infomation on how to get infomation about activities. This page gives some examples of using the API. This page has downloads for the Google API .NET library, which you can use to access the Google+ APIs, with XML documentation etc.

You'll need to use the API Console to get an API key and manage your API usage.

Also take a look at the API Explorer.

Here's a working example:

引用Google.Apis.dll和Google.Apis.Plus.v1.dll

Referencing Google.Apis.dll and 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

这篇关于如何获取谷歌加的post数据(喜欢 - 股 - 留言)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆