本文介绍了Android的Facebook的API后到墙上的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用Facebook的Andr​​oid SDK和张贴链接到Facebook。什么,我想会是一个例子是,如果你在Facebook和你输入一个链接到你的状态的一部分,如http://www.google.com。执行此操作时弹出一个框,和您的文章最终被具有图像和链接块。我发现,文档中的Facebook的API为这个使用attatchment,但是当我尝试了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.

推荐答案

Asuming当你读这一点,你知道如何通过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后到墙上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 00:44