简体   繁体   English

无法在Android中浏览Facebook专辑

[英]Not able to browsing the facebook albums in android

I am making one application in which I want to browse all the albums of facebook. 我正在制作一个应用程序,我想浏览facebook的所有专辑。 I used the following tutorial for it. 我使用了以下教程。

http://huguesjohnson.com/programming/java/android-fb-album/ http://huguesjohnson.com/programming/java/android-fb-album/

But not able to get the single data. 但无法获得单一数据。 I am getting null response from the facebook server. 我从facebook服务器得到null响应。

Can anyone help me to get facebook albums and its photos? 任何人都可以帮助我获取Facebook专辑及其照片吗?

Here is my code. 这是我的代码。

public class getUserImages extends AsyncTask<Void, Void, Void>
    {
        @Override
        protected Void doInBackground(Void... params) 
        {
            try
            {
             //invoke the API to get albums
              long startTime=System.currentTimeMillis();
              RestClient client = new RestClient("https://graph.facebook.com/" + PreferenceData.getUserId(FacebookIntegrationActivity.this) + "/albums?access_token="+mFacebook.getAccessToken());
              String albumsJson=client.execute(0);
              long endTime=System.currentTimeMillis();
              Log.d("==","Time to download albums="+(endTime-startTime)+"ms");
              Log.d("==","Album Json="+albumsJson);
            }
            catch (Exception e) 
            {
                e.printStackTrace();
            }
            return null;
        }
    }

The tutorial you've linked to doesn't include any authentication or login code as far as I can tell - I don't know to what extent you've implemented this. 就我所知,您链接到的教程不包含任何身份验证或登录代码 - 我不知道您实现此目的的程度。 From your code, with the access token added 'manually' it doesn't look like you are using the Facebook Android SDK to authenticate the user and log her in. 从您的代码中,通过“手动”添加访问令牌,您看起来并不像使用Facebook Android SDK对用户进行身份验证并将其登录。

These examples include code that use the SDK to do auth/login on Android. 这些示例包括使用SDK在Android上执行身份验证/登录的代码。

You need to ask for the "user_photos" permission from the user to be able to request album data successfully. 您需要向用户请求“user_photos”权限才能成功请求相册数据。

After you've authenticated and logged in the user, you can retrieve the albums by calling 在您进行身份验证并登录用户后,您可以通过调用来检索相册

mFacebookAsyncRunner.request(USER_ID+"/albums",new AlbumRequestListener());

where AlbumRequestListener extends the SDK's RequestListener. 其中AlbumRequestListener扩展了SDK的RequestListener。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM