0

我有代码来获取页面相册的所有照片。

String query = "SELECT pid FROM photo WHERE aid='100891649965116_15801'";
Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", query);
Utility.mAsyncRunner.request(null, params, new FQLRequestListener());

但是结果总是为空..我认为我的问题是我的应用程序中没有access_token ..如何解决我的问题,你能给我一些示例代码吗,谢谢

活动代码

public class TestBActivity extends Activity {
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        facebook.authorizeCallback(requestCode, resultCode, data);
    }

    Facebook facebook = new Facebook("386199591435293");

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        facebook.authorize(this, new DialogListener(){
            @Override
            public void onComplete(Bundle values) { }

            @Override
            public void onFacebookError(FacebookError e) { }

            @Override
            public void onError(DialogError e) { }

            @Override
            public void onCancel() {  }
        });

        Button btt = (Button)findViewById(R.id.button);
        btt.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View arg0) {
                String query = "SELECT pid FROM photo WHERE aid='100891649965116_15801'";
                Bundle params = new Bundle();
                params.putString("method", "fql.query");
                params.putString("query", query);      
                Utility.mAsyncRunner.request(null, params, new FQLRequestListener());               
            }
        });
   }

    public class FQLRequestListener extends BaseRequestListener{
        @Override
        public void onComplete(final String response, final Object state) {
           try {
                JSONArray json = new JSONArray(response);
                Log.d("tag", json.toString());
           } catch (JSONException e) {
                try {
                   JSONObject json = new JSONObject(response);
                   Log.d("tag2", json.toString());
                } catch (JSONException e1) {

                }
            }
        }

        public void onFacebookError(FacebookError error) {

        }
    }
}
4

0 回答 0