Android facebook sdk个人资料Feed

时间:2012-03-22 10:47:33

标签: android facebook

我是Facebook sdk新手,我需要创建一个应用程序

我知道如何张贴到墙上,办理登机手续,找朋友,

但我不知道如何获取Profile feed(Wall)和朋友提要

需要使用Graph API ??

但我不懂Graph API如何使用

1 个答案:

答案 0 :(得分:1)

使用Facebook弹出窗口:

public void share(String day, String points)
{
    Bundle params = new Bundle();
    params.putString("name", XXXXXXXX);
    params.putString("caption", XXXXXXXX);
    params.putString("link", XXXXXXXX);
    params.putString("description",XXXXXXXX);
    facebook.dialog(this, "stream.publish",params , new WallPostDialogListener());      
}

class WallPostDialogListener implements DialogListener 
{
    public void onComplete(Bundle values) 
    {
        if(data.facebook == true)
        {
            Log.e("SHARE",values.toString());
            if(values.getString("post_id")!=null)
            {

            }
        }

    }
    public void onFacebookError(FacebookError e) 
    {
        Log.d("PostToWall","Facebook Error");
    }
    public void onError(DialogError e) 
    {
        Log.d("PostToWall","Dialog error");
    }
    public void onCancel() 
    {
        Log.d("PostToWall","Cancel");
    }
}

没有Facebook对话框:

Bundle parameters = new Bundle();
parameters.putString("name", XXXXXXXX);
parameters.putString("message", XXXXXXXX);
parameters.putString("link", XXXXXXXX);
response = facebook("me/feed", parameters, "POST");

尝试:https://developers.facebook.com/docs/reference/api/

例如: (我不知道这是否有效)

Bundle parameters = new Bundle();
response = facebook("me/feed", parameters, "GET");
JSONObject feeds = new JSONObject();
try
{
     feeds = new JSONObject(response);
}
catch(JSONException e)
{}

或:

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);  
mAsyncRunner.request("me/feed", new FeedsRequestListener());

    private class FeedsRequestListener implements RequestListener 
    {           
            @Override
            public void onComplete(String response, Object state) 
            {
                    try 
                    {
                            JSONObject json = Util.parseJson(response);
                    } 
                    catch (JSONException e) 
                    {
                            Log.e("OnComplete","JSONException");
                    }
                    catch (FacebookError e) 
                    {
                            Log.e("OnComplete","FacebookError");
                    }
            }
            @Override
            public void onIOException(IOException e, Object state)
            {
                    Log.e("FeedsRequest","onIOException " + e.toString());
            }
            @Override
            public void onFileNotFoundException(FileNotFoundException e,Object state)
            {
                    Log.e("FeedsRequest","onFileNotFoundException " + e.toString());
            }
            @Override
            public void onMalformedURLException(MalformedURLException e,Object state)
            {
                    Log.e("FeedsRequest","onMalformedURLException " + e.toString());
            }
            @Override
            public void onFacebookError(FacebookError e, Object state)
            {
                    Log.e("FeedsRequest","onFacebookError " + e.toString());
            }
    }