安卓 & facebook Stream.publish 问题...救命!
大家好,
我遇到了一件奇怪的事情。我有一个可以工作的代码,但现在不再工作了。对我来说,我认为我没有做出任何改变...有人可以告诉我出了什么问题吗? 我正在尝试使用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
附件变量需要进行 URL 编码!
The attachment variable need to be URL Encoded !!