android facebook api 将图像贴到墙上 [英] android facebook api post to wall with image

查看:20
本文介绍了android facebook api 将图像贴到墙上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用 facebook android sdk 并发布到 facebook 的链接.我想要的一个例子是,如果您在 facebook 上并在您的状态部分键入一个链接,例如http://www.google.com".当您执行此操作时,会弹出一个框,您的帖子最终成为一个包含图像和链接的块.我使用附件在 facebook api 中找到了相关文档,但当我尝试使用 android facebook api 执行此操作时,它似乎不起作用.我在网上找了几个小时,没有运气.谢谢.

I would like to be able to use the facebook android sdk and post a link to facebook. An example of what I want would be is if you were on facebook and you type a link into your status part, like "http://www.google.com". When you do this a box pops up and your post ends up being a block that has an image and a link. I found documentation in the facebook api for this using an attatchment, though when I try to do this with the android facebook api it doesn't seem to work. I've looked for hours on the net, with no luck. Thanks.

推荐答案

假设当您阅读本文时,您知道如何通过 api 登录 facebook 等...

Asuming when you read this that you know how to log onto facebook and such via the api...

  private void fbImageSubmit(Facebook fb, String imageurl, String caption, String description, String name, String linkurl)
    {
        if(fb != null)
        {
            if(fb.isSessionValid())
            {
                Bundle b = new Bundle();
                b.putString("picture", imageurl);
                b.putString("caption",caption);
                b.putString("description",description );
                b.putString("name",name);
                b.putString("link",linkurl);
                try {
                    String strRet = "";
                    strRet = fb.request("/me/feed",b,"POST");
                    JSONObject json;
                    try {
                        json = Util.parseJson(strRet);
                        if(!json.isNull("id"))
                        {
                            Log.i("Facebook", "Image link submitted.");
                        }
                        else
                        {
                            Log.e("Facebook","Error: " + strRet);
                        }
                    } catch (FacebookError e) {
                        Log.e("Facebook","Error: " + e.getMessage());
                    }
                } catch (Exception e) {
                    Log.e("Facebook", "Error: " + e.getMessage());
                }
            }
        }
    }

这篇关于android facebook api 将图像贴到墙上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆