Android facebook api post

I have a problem. I want to use facebook api and make a message on the wall without calling a dialog. Mostly I have an application and I want people to be able to share this application, so I want to have a special message. I keep getting the answer "Method not implemented." Here is the code for the message.

//I tried this also ->>String path = "http://graph.facebook.com/me/feed"; String path = "https://api.facebook.com/method/stream.publish"; Bundle b = new Bundle(); //And i tried this -> b.putString("access_token",facebook.getAccessToken()); b.putString("message", "this is just a test..."); try { String ret = facebook.request(path, b); Toast.makeText(fmasterActivity.this, ret, Toast.LENGTH_LONG).show(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } 
+4
source share
1 answer

I assume that you are executing this bit of code after a successful user authentication?

This bit of code worked for me:

 private Facebook mFacebook; private AsyncFacebookRunner mAsyncRunner; private void onFacebookShare() { mFacebook = new Facebook(); mAsyncRunner = new AsyncFacebookRunner(mFacebook); SessionEvents.addAuthListener(new SampleAuthListener()); SessionEvents.addLogoutListener(new SampleLogoutListener()); } private void postToFBWall() { if(mFacebook.isSessionValid()){ shareVideoOnFB(); } else { showDialog(DIALOG_FBOOK_LOGIN); } } public void shareVideoOnFB(){ Bundle params = new Bundle(); params.putString("message", "This string will appear as the status message"); params.putString("link", "This is the URL to go to"); params.putString("name", "This will appear beside the picture"); params.putString("caption", "This will appear under the title"); params.putString("description", "This will appear under the caption"); params.putString("picture", "This is the image to appear in the post"); mAsyncRunner.request("me/feed", params, "POST", new RequestListener() { public void onMalformedURLException(MalformedURLException e) {} public void onIOException(IOException e) {} public void onFileNotFoundException(FileNotFoundException e) {} public void onFacebookError(FacebookError e) {} public void onComplete(String response) { logoutFacebook(); } }); Toast.makeText(ShareActivity.this, "Posting to your Wall...", Toast.LENGTH_SHORT).show(); } 

You can call onFacebookShare () in your onCreate () activity, and then when the user clicks everything to indicate that he / she wants to share on Facebook, call postToFBWall (). Of course, you need to add processing to display the login dialog.

+9
source

All Articles