安卓 & facebook Stream.publish 问题...救命!

发布于 2024-09-27 13:52:57 字数 1107 浏览 2 评论 0原文

大家好,

我遇到了一件奇怪的事情。我有一个可以工作的代码,但现在不再工作了。对我来说,我认为我没有做出任何改变...有人可以告诉我出了什么问题吗? 我正在尝试使用stream.publish 的附件方法发布带有图像和链接的文本。

这是代码:

            Bundle myParams = new Bundle();
            myParams.putString("message", "Je publie un TEST.");

            String attachment="{\"name\":\"Gran Turismo 5\",\"href\":\"http://www.unknown.com/?lang=fr\",\"caption\":\"Sony Computer Entertainment\",\"description\":\"Une vidéo proposée par Cedemo.\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.unknown.com/prepicture//thumb_title/15/15061_1.jpg\",\"href\":\"http://www.unknown.com/?lang=fr\"}],\"properties\":{\"Autre lien\":{\"text\":\"Cedemo\",\"href\":\"http://www.unknown.com\"}}}";

            myParams.putString("attachment",attachment);
            mFacebook.dialog(Example.this,"stream.publish",myParams, new PostSampleDialogListener());

发生的情况是我只收到 Facebook 上发布的“消息”文本,而没有收到任何有关我的附件的信息...该函数没有返回错误代码。我不明白,这段代码之前一直在工作......

解决方案

你必须你必须使用函数 URLEncoder.encode 来编码你的参数。 例子 : myParams.putString("附件", URLEncoder.encode("{\"名称\":\""..... ))

HI all,

Im having a strange thing. Im having a code that was working that doesnt anymore. To me, I think i didnt make any changes...Can someone give me an idea what is wrong ??
I'm trying to publish a text with an image and a link using the attachment method of stream.publish.

here is the code :

            Bundle myParams = new Bundle();
            myParams.putString("message", "Je publie un TEST.");

            String attachment="{\"name\":\"Gran Turismo 5\",\"href\":\"http://www.unknown.com/?lang=fr\",\"caption\":\"Sony Computer Entertainment\",\"description\":\"Une vidéo proposée par Cedemo.\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.unknown.com/prepicture//thumb_title/15/15061_1.jpg\",\"href\":\"http://www.unknown.com/?lang=fr\"}],\"properties\":{\"Autre lien\":{\"text\":\"Cedemo\",\"href\":\"http://www.unknown.com\"}}}";

            myParams.putString("attachment",attachment);
            mFacebook.dialog(Example.this,"stream.publish",myParams, new PostSampleDialogListener());

What is happening is that I am getting only the "Message" text published on facebook and nothing about my attachment... There is no error code returned by the function. I dont understand, this code has been working before...

THE SOLUTION

You have to You have to use the function URLEncoder.encode to encode your parameters.
Example :
myParams.putString("attachment", URLEncoder.encode("{\"name\":\""..... ))

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

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

发布评论

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

评论(1

凉薄对峙 2024-10-04 13:52:57

附件变量需要进行 URL 编码!

The attachment variable need to be URL Encoded !!

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