I have to send a link on user’s facebook wall. I am trying but not getting success.
I wrote the code but its not working. First i write:
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import com.facebook.android.AsyncFacebookRunner;
import com.facebook.android.DialogError;
import com.facebook.android.Facebook;
import com.facebook.android.FacebookError;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class FacebookActivity extends Activity {
/** Called when the activity is first created. */
Facebook face;
AsyncFacebookRunner run;
String[] permission=new String[] {"publish_stream",
"read_stream", "offline_access"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
face=new Facebook("my key");
run=new AsyncFacebookRunner(face);
face.authorize(this, permission,new MyLoginDialogListener());
}
private final class MyLoginDialogListener implements com.facebook.android
.Facebook.DialogListener {
public void onComplete(Bundle values) {
Toast.makeText(FacebookActivity.this, "Ho Gya Authorize",Toast.LENGTH_LONG).show();
run=new AsyncFacebookRunner(face);
Bundle bundle=new Bundle();
bundle.putString("message", " hello");
bundle.putString("name", "hello");
bundle.putString("description", "Hello");
bundle.putString("link", "http://www.facebook.com");
try {
face.request("me/feed",bundle, "POST");
} 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();
}
} // here enable logout
public void onFacebookError(FacebookError error) {}
public void onError(DialogError error) {}
public void onCancel() {}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
face.authorizeCallback(requestCode, resultCode, data);
}
}
Please suggest how to proceed further. My code is not posting on the wall of user’s wall.
Sample code for posting wall on facebook
}