使用 Hammock lib 在 LinkedIn 上发布共享时出错

发布于 2024-12-27 12:59:54 字数 1522 浏览 5 评论 0原文

尝试在 Linkedin 人员上发送新的分享。这是我的客户端代码:

                RestClient client = new RestClient()
                {
                    Authority = "http://api.linkedin.com/v1",
                    Credentials = this.AccessCredentials(connectionData.ApplicationKey, connectionData.ApplicationSecret, connectionData.AccessToken, connectionData.AccessSecret),
                    Method = WebMethod.Post,
                    Encoding = Encoding.UTF8,

                };

                RestRequest request = new RestRequest()
                {
                    Path = "people/~/shares",
                    Encoding = Encoding.UTF8,
                };

                Share share = new Share(socialMessage.Text, socialMessage.Name, socialMessage.Description, VisibilityCode.Anyone);
                share.Content.SubmittedImageUrl = socialMessage.PictureLink;
                share.Content.SubmittedUrl = socialMessage.Link;

                String content = Utilities.SerializeToXml<Share>(share);

                client.AddPostContent(System.Text.Encoding.UTF8.GetBytes(content));
                client.AddHeader("Content-Type", "text/xml");

                request.AddPostContent(System.Text.Encoding.UTF8.GetBytes(content));
                request.AddHeader("Content-Type", "text/xml");

                RestResponse response = client.Request(request);

在调用“无法解析共享文档:错误:空后文件意外结束”之后,我总是收到此错误消息。

有谁可以告诉我如何使用 Hammock 库向 LinkedIn 发送帖子?

谢谢&问候

I'm trying to send a new Share on a Linkedin Person. This is my client code:

                RestClient client = new RestClient()
                {
                    Authority = "http://api.linkedin.com/v1",
                    Credentials = this.AccessCredentials(connectionData.ApplicationKey, connectionData.ApplicationSecret, connectionData.AccessToken, connectionData.AccessSecret),
                    Method = WebMethod.Post,
                    Encoding = Encoding.UTF8,

                };

                RestRequest request = new RestRequest()
                {
                    Path = "people/~/shares",
                    Encoding = Encoding.UTF8,
                };

                Share share = new Share(socialMessage.Text, socialMessage.Name, socialMessage.Description, VisibilityCode.Anyone);
                share.Content.SubmittedImageUrl = socialMessage.PictureLink;
                share.Content.SubmittedUrl = socialMessage.Link;

                String content = Utilities.SerializeToXml<Share>(share);

                client.AddPostContent(System.Text.Encoding.UTF8.GetBytes(content));
                client.AddHeader("Content-Type", "text/xml");

                request.AddPostContent(System.Text.Encoding.UTF8.GetBytes(content));
                request.AddHeader("Content-Type", "text/xml");

                RestResponse response = client.Request(request);

I always obtain this error message after the call "Couldn't parse share document: error: Unexpected end of file after null".

Does anyone can tell me how to use Hammock library to send a POST to LinkedIn?

Thanks & Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溺深海 2025-01-03 12:59:54

这里也有可能的解决方案:
https://github.com/danielcrenna/hammock/issues/4

Also there is possible solution here:
https://github.com/danielcrenna/hammock/issues/4

冰之心 2025-01-03 12:59:54

我不确定如何使用 hammock 库,但您可以使用以下提示调试 LinkedIn(或任何其他 Web 服务)的 API 调用:
http://developer.linkedin.com/documents/debugging-api-calls

这将向您展示如何安装 HTTP 嗅探器并观察流量以了解发生了什么。完成此操作后,如果仍有问题,请将其发布,这样就可以调试出现问题的地方。

I'm not sure how to use the hammock library, but you can debug API calls for LinkedIn (or any other web service) using the tips at
http://developer.linkedin.com/documents/debugging-api-calls

This will show you how to install an HTTP sniffer and watch the traffic to see what's happening. Once you've done that, if you're still having issues post them and it'll be possible to debug what's going wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文