2012-12-01 34 views
-1

我做了如下編碼:創建一個Facebook事件的Android

裏面的onCreate()我說:

Facebook fc = new Facebook("392736034134808"); 
    AsyncFacebookRunner mAsuncRunner = new AsyncFacebookRunner(fc); 
    mAsuncRunner.request("/me/events",new EventRequestListener()); 

我EventReqestListner類,它是下面的onCreate()是這樣的:

 class EventRequestListener implements 
com.facebook.android.AsyncFacebookRunner.RequestListener { 


public void onComplete(final String response) throws JSONException{   

System.out.println("in oncomplete of friend request listner ...."); 
String Name= "test"; 
String Location= "test"; 
String Description= "desc"; 
JSONObject event = new JSONObject(); 
Bundle bundle = new Bundle(); 
bundle.putString("method","events.create"); 
event.put("page_id",123454); 
event.put("name",Name); 
event.put("location",Location); 
event.put("start_time", "2013-05-14T10:13:00"); 
event.put("end_time", "2013-05-15T10:20:00"); 
event.put("privacy_type", "OPEN"); 
bundle.putString("event_info",event.toString()); 

try { 
    fc.request("POST", bundle); 
} catch (MalformedURLException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} catch (IOException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 
System.out.println("Event Posted"); 
} 

我的問題是這樣的,我沒有得到任何錯誤,例外。另外我做網絡創建的事件。我對android非常陌生,你的幫助非常有價值。 謝謝!

回答

0

您需要處理auth和login,然後才能請求用戶的事件。這包括要求用戶的權限允許您的應用程序檢索事件。

當前你的代碼實例化一個Facebook對象。在此之後,你需要進行身份驗證和登錄的用戶中的一些資源,幫助你實現這個是:

此外,您的RequestListener代碼不正確。目前它正試圖將數據發佈到FB。它通常用於從 FB解析來自的數據。查看上面鏈接中的示例,瞭解如何使用RequestListener。

+0

非常感謝!我會通過他們所有.. :) – TharakaNirmana