所以我写了一个很好的FQL查询
select uID,name,pic_square,is_app_user from user where uID in (select uID2 from frIEnd where uID1 = me())
现在,我所要做的就是运行它.
由于对返回朋友列表似乎很好的唯一请求是Request.executeMyFrIEndsRequestAsync和Request.newMyFrIEndsRequest,我认为他们是我的朋友,但是两者都不允许微调FQL查询.
如何发送查询并返回一个朋友列表或至少一个JsONArray?
Hackbook – FQL query教程正在使用旧版本的SDK,我不知道该怎么做.
更新:
我添加了这些代码行,它会让我创建这个查询:
public voID onCreate(Bundle savedInstanceState) { // SOME CODE this.openSession();}protected voID onSessionStateChange(SessionState state,Exception exception) { if (state.isOpened()) { Session activeSession = getSession().getActiveSession(); facebook.setAccesstoken(activeSession.getAccesstoken()); facebook.setAccessExpires(activeSession.getExpirationDate().getTime()); Request req = Request.newMyFrIEndsRequest(activeSession,new GraphUserListCallback() { @OverrIDe public voID onCompleted(List<GraphUser> users,Response response) { System.out.println(response.toString()); } }); Bundle params = new Bundle(); params.putString("method","fql.query"); params.putString("query","select uID,is_app_user " + "from user where uID in " + "(select uID2 from frIEnd where uID1 = me())"); req.setParameters(params); Request.executeBatchAsync(req); }}
我这样做,认为它会编辑请求并添加我想要的信息,但我有这个错误:
10-31 09:36:31.647: E/AndroIDRuntime(15986): java.lang.NullPointerException10-31 09:36:31.647: E/AndroIDRuntime(15986): at com.sample.facebook.to.db.MainActivity.onCompleted(MainActivity.java:62)10-31 09:36:31.647: E/AndroIDRuntime(15986): at com.facebook.Request.onCompleted(Request.java:269)10-31 09:36:31.647: E/AndroIDRuntime(15986): at com.facebook.Request.run(Request.java:1197)10-31 09:36:31.647: E/AndroIDRuntime(15986): at androID.os.Handler.handleCallback(Handler.java:587)10-31 09:36:31.647: E/AndroIDRuntime(15986): at androID.os.Handler.dispatchMessage(Handler.java:92)10-31 09:36:31.647: E/AndroIDRuntime(15986): at androID.os.Looper.loop(Looper.java:130)10-31 09:36:31.647: E/AndroIDRuntime(15986): at androID.app.ActivityThread.main(ActivityThread.java:3691)10-31 09:36:31.647: E/AndroIDRuntime(15986): at java.lang.reflect.Method.invokeNative(Native Method)10-31 09:36:31.647: E/AndroIDRuntime(15986): at java.lang.reflect.Method.invoke(Method.java:507)10-31 09:36:31.647: E/AndroIDRuntime(15986): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)10-31 09:36:31.647: E/AndroIDRuntime(15986): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:665)10-31 09:36:31.647: E/AndroIDRuntime(15986): at dalvik.system.NativeStart.main(Native Method)解决方法 你会做这样的事情:
String fqlquery = "select uID,is_app_user from user where uID in (select uID2 from frIEnd where uID1 = me())";Bundle params = new Bundle();params.putString("q",fqlquery);Session session = Session.getActiveSession();Request request = new Request(session,"/fql",params,httpMethod.GET,new Request.Callback(){ public voID onCompleted(Response response) { Log.i(TAG,"Got results: " + response.toString()); }});Request.executeBatchAsync(request);
您基本上将一个Graph API请求发送到“/ fql”端点,并将查询传递给“q”参数.
总结以上是内存溢出为你收集整理的如何使用新的Android SDK发送FQL查询全部内容,希望文章能够帮你解决如何使用新的Android SDK发送FQL查询所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)