Tuesday 15 February 2011

android - Publish photo on facebook -


I'm trying to Share a photo and Andoid application , On Facebook using Facebook SDK I have done

  Facebook FB; String APP_ID = "xxxxx"; // xxxxx: is my app id private static last string [] permission = new string [] {"publish_stream"}; Private stable final string token = "access_token"; Personal Static Final String Xperia = "expires_in"; Private Static Last String Key = "Facebook-Credentials"; MSharebutton = (button) Find VibibIID (R.Ded.Sher_Button); mShareButton.setOnClickListener (New View.OnClickListener () {public void onClick (View v) {restoreCredentials (FB); messageToPost = "Hello everyone."; if (fb.isSessionValid ()) {loginAndPostToWall () ;!} public Boolean restoreCredentials (Facebook) {SharedPreferences SharedPreferences = getApplicationContext () .getSharedPreferences (key, Context.MODE_PRIVATE); facebook.setAccessToken (sharedPreferences.getString (tokens, null)); finished facebook.setAccessExpires (sharedPreferences.getLong (, 0) will); return facebook.isSessionValid ();} public void loginAndPostToWall () {fb.authorize (allowing, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener ());} public void postPhotoToWa ll () {Bitmap bmp = BitmapFactory.decodeResource (getResources (), R .drawable.melody); ByteArrayOutputStream stream = new Baitareonputstrym (); bmp.compress (bitmap. Compresformetkpianji, 100, stream); final byte [] data = stream. Tueteare (); Bundle parameter = new Bundle (); parameter Kputstring ( "message", "Mess Age"); Parameters.putByteArray ("Picture", Data); Parameters.putString ("caption", "test"); Try {log. ("Test", "got answer:"); Fb.request ("me / feed"); Logs. I ("test", "got answer:"); String response = fb.request ("me / feed", parameter, "post"); Log D. ("Test", "reply found:" + response); If (feedback == null) response.equals ("") || response.equals ("wrong")} {showToast ("empty response".); } Other {showToast ("The photo was posted in your Facebook wall!"); }} (Exception e) {showToast ("Failed to post photos on your Facebook wall!"); E.printStackTrace (); }}   

When I click the share button, I can get just the app ID from my account. Apart from this, I can not post photos on the wall: I just have to "Failed to post photos to my Facebook Wall!" I can not understand this problem. Any help please

Please refer to this link, I have provided sample code here:

No comments:

Post a Comment