ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

c# – 如何获取Google Plus的帖子数据(喜欢 – 分享 – 评论)?

2019-06-13 15:04:27  阅读:202  来源: 互联网

标签:c net c-4-0 google-plus api


使用C#,我想阅读像这个https://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD这样的Google帖子的分享,评论和喜欢

解决方法:

那篇文章是一项活动. This page包含有关如何获取活动信息的信息. This page给出了一些使用API​​的示例. This page提供了Google API .NET库的下载,您可以使用它来访问Google API,使用XML文档等.
您需要使用API Console获取API密钥并管理您的API使用情况.
另外看看API Explorer.
这是一个有效的例子:

引用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

标签:c,net,c-4-0,google-plus,api
来源: https://codeday.me/bug/20190613/1233684.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有