FQL Facebook API返回null值

时间:2012-07-31 14:23:52

标签: android facebook facebook-fql

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

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());

但是结果总是空的..我认为我的问题是我的app中没有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) {

        }
    }
}

0 个答案:

没有答案