2011-12-16 57 views
-1

我有這樣的代碼創建使用Facebook的舊的API

 JSONObject event = new JSONObject(); 
     Bundle bundle = new Bundle(); 
     bundle.putString("method","events.create"); 
     event.put("name", "name"); 
     event.put("location", "Address"); 
     event.put("start_time", "2011-12-15T10:13:00"); 
     event.put("end_time", "2011-12-15T10:20:00"); 
     event.put("privacy_type", "OPEN"); 
     event.put("event_info", "INFO"); 
     Log.d(TAG,"evento "+mFacebook.request(bundle)); 

這個錯誤在Android的事件......

   {"error_code":100,"error_msg":"The parameter event_info is              required","request_args": [{"key":"access_token","value":"asdasdasd"},{"key":"method","value":"events.create"},{"key":"format","value":"json"}]} 

我使用的是舊的API ...如果你知道創建活動在Android中使用新的API我會很感激

在此先感謝

+0

嗨benoffi7 ..我也試圖從我的應用程序添加事件。我沒有任何想法。你可以發表一些代碼..謝謝 – wolverine 2012-08-10 13:08:24

+0

嗯狼獾!在我的問題下有一個正確的答案。嘗試在你的應用中做到這一點。 – benoffi7 2012-08-10 17:19:39

回答

1

您可以使用event創建Graph API:發送POST請求。我嘗試使用參數:name,start_time,end_time,description,privacy_type。 如果我正確理解重新命名參數只有名稱和start_time。如果你沒有設置end_time,它將是相等的start_time + 3h。默認情況下,隱私是開放的。 但我不明白,你想從event_info? 您可以添加到POST字段位置。或者你想發送擴展信息與facebook對象作爲一些地方(如在圖形API場地)?

0

您的語法問題。 event_info標籤採取jsonObject不是字符串。您必須傳遞Json對象作爲event_info的參數。這是我的工作代碼。嘗試這個。

JSONObject json = null; 

         try { 
      json = new JSONObject(); 
      json.put("privacy_type", "OPEN"); 
      json.put("name", mEventName.toString()); 
      json.put("start_time",mCurrentDateTime); 
      json.put("end_time", mExpiryDateTime); 
      json.put("description",mEventName.toString()); 
     } catch (JSONException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    Bundle params = new Bundle(); 
    params.putString("method", "events.create"); 

    params.putString("event_info", json.toString()); 
    String response = ""; 
    try { 
     response = facebook.request(params); 
     Log.d("gaurav", "response of create events ="+response); 
    } catch (FileNotFoundException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (MalformedURLException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

這對我很好,我希望它能爲你工作。

相關問題