请使用Graph API帮助我创建Facebook活动。在我的Android Facebook App中,我创建了一个菜单登录,getfriend,wallpost和create event。我需要帮助创建事件或源代码。
这是我的代码:
public class EventRequestListener implements
com.facebook.android.AsyncFacebookRunner.RequestListener {
public void onComplete(final String response) throws JSONException, MalformedURLException, IOException {
/*Log.d("Facebook-Example-Event","response.length(): " + response.length());
Log.d("Facebook-Example-Event", "Response: " + response);*/
mSpinner.dismiss();
Intent myIntent = new Intent(response, null, getApplicationContext(), null);
myIntent.putExtra("API_RESPONSE", response);
myIntent.putExtra("METHOD", "events.create");
startActivity(myIntent);
JSONObject event = new JSONObject();
Bundle bundle = new Bundle();
bundle.putString("method","events.create");
event.put("page_id","groupid");
event.put("name", "App event test");
event.put("description", "it is for testing application");
event.put("location", "locationtest");
event.put("start_time", "2011-05-14T10:13:00");
event.put("end_time", "2011-05-15T10:20:00");
event.put("privacy_type", "OPEN");
// bundle.putString("event_info",event.toString());
Log.d(TAG,"evento "+mFacebook.request(bundle));
mFacebook.request("POST", bundle);
}
public void onFacebookError(FacebookError e) {
// Ignore Facebook errors
}
public void onFileNotFoundException(FileNotFoundException e) {
// Ignore File not found errors
}
public void onIOException(IOException e) {
// Ignore IO Facebook errors
}
public void onMalformedURLException(MalformedURLException e) {
// Ignore Malformed URL errors
}
@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
}
}
//main menu:
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Login/logout toggle
case R.id.login:
// Toggle the button state.
// If coming from login transition to logout.
if (mFacebook.isSessionValid()) {
AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(mFacebook);
asyncRunner.logout(this.getBaseContext(), new LogoutRequestListener());
} else {
// Toggle the button state.
// If coming from logout transition to login (authorize).
mFacebook.authorize(this, PERMISSIONS, new LoginDialogListener());
}
break;
// Wall Post
case R.id.wallpost: // Wall Post
mFacebook.dialog(SampleApp.this, "stream.publish", new WallPostDialogListener());
break;
// Get Friend's List
case R.id.getfriends: // Wall Post
// Get the authenticated user's friends
mSpinner.show();
graph_or_fql = "graph";
Bundle params = new Bundle();
params.putString("fields", "name, picture, location");
mAsyncRunner.request("me/friends", params,
new FriendsRequestListener());
//mAsyncRunner.request("me/friends", new FriendsRequestListener());
break;
case R.id.createvent:
//String data;
//mSpinner.show();
mAsyncRunner.request("me/events",new EventRequestListener());
break;