通过.NET使谷歌加柱(C#)NET、使谷歌加柱

2023-09-03 07:03:04 作者:Sadness 忧伤

你好所有。

有没有人有这方面的例子,如何通过.NET(C#),使谷歌加后。

Does anyone has a working example how to make Google Plus post through .NET (C#).

我已经尝试过谷歌和计算器搜索,但没能找到解决办法。

I have already tried google and stackoverflow search, but did not manage to find the solution.

我顺利拿到帖子:

    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);
    }

但我找不到任何方法制作的帖子。

But I cannot find any method for making posts.

在此先感谢。

推荐答案

目前,在Google+的API不允许职位写入用户的活动流。您可以使用 moments.insert方法在Google+的REST API 写应用活动以用户的配置文件,用户可以选择是否公开或分享自己的圈子。

Currently, the Google+ API does not allow writing of posts to a user's activity stream. You can use the moments.insert method in the Google+ REST API to write App Activities to the user's profile, which the user can choose whether to share publicly or to their circles.

您将与REST API的工作以类似的方式向其他的REST API在.NET中张贴到的 moments.insert 终点。

You would work with the REST API in a similar manner to other REST APIs in .NET by POSTing to the moments.insert end-point.

此功能现在可用于该请求 https://www.googleapis.com/auth/plus.login 范围和指定的时刻的类型的应用程序要在 request_visible_actions 参数无论是在 Google+登录功能按钮或直接在OAuth的查询参数。

This feature is now available to apps that request the https://www.googleapis.com/auth/plus.login scope and specify the type of moments that the app wants to write in the request_visible_actions parameter either in the Google+ Sign-In button or directly in the OAuth query parameters.

 
精彩推荐
图片推荐