Send a private message to my friends using myroid app

I am developing an application in which a user can share messages with his friends on Facebook. I am using the Facebook API for Android. I can verify the authenticity of the user, as well as get a list of friends as a Facebook user, and also send a message on the wall, but I am looking to send a personal message to my friends, and I have not received any solution for this, so can any body help me, how can i achieve ...

Thank you in advance

Regards

+15
android facebook
May 26 '12 at 7:13
source share
4 answers

It is not possible to send private messages on behalf of the user using the api schedule.

However, you should use the Send Dialog , although I have not tried it on Android, but it should be something like:

Bundle params = new Bundle(); params.putString("to", "USER_ID"); params.putString("name", "TITLE HERE"); params.putString("link", "A URL"); // this link param is required facebook.dialog(context, "send", params, new DialogListener() { @Override public void onComplete(Bundle values) { .... } @Override public void onFacebookError(FacebookError error) {} @Override public void onError(DialogError e) {} @Override public void onCancel() {} }); 

Another approach you can use is the chat API , with which you can send messages as a user, this requires xmpp_login permission, and you must implement the xmpp client.




Edit

Since this dialog is not yet supported on Android, you have 3 options:

  • Wait for the dialog box for Android to appear on facebook.
  • Try opening a dialog box in a browser (the URL that is in the documents) on your mobile device.
  • Request xmpp_login and add the xmpp client (for example: asmack ), and with this you can implement your own Send Message dialog box.
+7
May 26 '12 at 10:58 a.m.
source share

New Android SDKs now have (private) message dialog
https://developers.facebook.com/docs/android/message-dialog/

0
May 2 '14 at 7:45
source share

You can use MessengerUtils to send message with attachments.

enter image description here

You can send an attachment with the following mime types:

enter image description here

An example code for sending an image looks below

 String mimeType = "image/jpeg"; // contentUri points to the content being shared to Messenger ShareToMessengerParams shareToMessengerParams = ShareToMessengerParams.newBuilder(contentUri, mimeType) .build(); // Sharing from an Activity MessengerUtils.shareToMessenger( this, REQUEST_CODE_SHARE_TO_MESSENGER, shareToMessengerParams); 

enter image description here

Additional documentation is at https://developers.facebook.com/docs/messenger/android

0
06 Sep '16 at 16:28
source share

You can send a personal facebook message using the code below.

 if (isPackageExisted("com.facebook.orca")) { Uri uri = Uri.parse("fb-messenger://user/"); uri = ContentUris.withAppendedId(uri, Long.parseLong("Enter user id here")); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } else { Toast.makeText(this, "Please install facebook messenger", Toast.LENGTH_LONG).show(); } } 

Check that Facebook messenger is installed or not

  public boolean isPackageExisted(String targetPackage) { PackageManager pm = getPackageManager(); try { PackageInfo info = pm.getPackageInfo(targetPackage, PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { return false; } return true; } 
0
Feb 27 '17 at 6:16
source share



All Articles