how to send message in friends message folder/inbox in facebook? - javascript

I want to send message to facebook friend's inbox/message folder from my application using either javascript or php sdk How can I do that?
Before, this we used
FB.api('me/feed', 'post' ......
method to post in friends wall from my application but now that method is removed from FEB 2013, I also tried sending mail at
FACEBOOK_FRIENDS_USERNAME#facebook.com
but this method also didn't work all the time some time message was going to others folder in messages but not all the time, Can anyone tell me why this is happening? I rechecked my code, the username was correct to where I was sending the mail.
I have also tried
FB.ui({method : 'send', .....
method but it opens one dialog for sending message and then we have to select multiple friends I don't want that, I want to send message to user's facebook friends directly from my application.
If there is some other way to implement this please help me?

You can't send message to a User's friend you can only read User's messages throgh the application ,check this link.
But if you still need the functionality to either post on the friend's wall or send message to a User's friend you can use Facebook JavaScript SDK's share.stream method
<script>
var share = {
method: 'stream.share',
u: 'http://www.fbrell.com/'
};
FB.ui(share, Log.info.bind('stream.share callback'));
</script>
or you can utilize Send Dialog

Related

Facebook messenger account linking, how to use it?

There are 4 easy steps described in the documentation about account linking for the messenger platform:
Register a callback URL using Log In Button.
Messenger Platform invokes the registered URL when a user starts the account linking flow. The redirect_uri and account_linking_token parameters are appended to your registered callback.
Once linking is complete, redirect users to the location provided by redirect_uri and append a authorization_code parameter (defined by you) to confirm linking.
Optionally retrieve the user's page-scoped ID (PSID) using the account linking endpoint. This step should only be used in special cases when you need the user's PSID as part of the linking process.
These steps are very easy to follow, except there's no help whatsoever on how to actually link the account, I get the redirect_uri and the account_linking_token as parameters on my callback website where I enter the account login and password.
And then, I link the accounts...? How exactly?
What's the use on this button? I know it is supposed to link accounts, but what do I need the account_linking_token for? I can already send in a regular web_url button the user psid, I can easily send it on my login button as a parameter and link account to this psid if credentials are correct.
I strongly believe there's something I'm missing or something I'm not understanding, but I don't know what. I followed the steps, called the account linking endpoint to get the PSID, which I already had since it is how I send messages with my bot, but I don't really see the point on this button.
So, what am I missing? I'm so frustated.
Just been through a similar bit of head scratching, so will explain what I've done while it's fresh in my head
For my example, I wanted Facebook to redirect out to my main login page, which is an open id connect implementation. The customer signs in to this, and I get an id_token and access_token back from that. Upon receiving the access_token, I'm extracting the 'sub' claim from the JWT, which is the unique customer identifier in our database.
I'm then redirecting back to the value that was sent to me in redirect_uri, appending authorization_code={the-value-of-the-sub-claim}
This then triggers the 'account link' webhook, which will Post to my service code, containing the PSID of the Facebook user and the authorization_code, which is my unique customer id in my business database.
You now have the 2 bits of information you need, the unique facebook id and your unique customer id in the Post message. It's up to your business code to persist this information to some sort of storage at this point
On subsequent message posts to the Bot endpoint, you always have the sender (PSID) in the message. Your code can now look up the corresponding id specific to your business and perform operations relevant for that id.
Where the linking takes place - that's in your code, you need to handle the message from the account link webhook and store the data for future use.

Sending message on Intercom on user's behalf

does anyone know how to send a message from intercom(https://www.intercom.com/) on user's behalf? I need to set up an event listener that opens intercom chat window and sends a message when a some button is clicked.
i am working with react version of intercom if it helps.
will be very grateful for any hints.
If you are using the Intercom chat widget, you can pre-populate a custom message in the widget on the user's behalf like so
const myCustomMessage = 'Hi there!'
window.Intercom('showNewMessage', myCustomMessage)
Of course, the user still has to actually send the message. This might not be exactly what you wanted but it's an alternative in case you want to fully automate everything except the decision to send the message (which is the right UX in a lot of situations).
Documentation is here.
for those who are in the same trouble:
https://developers.intercom.com/reference#user-or-contact-initiated-conversation
For sending messages on the user's behalf, you may check this out https://developers.intercom.com/intercom-api-reference/reference/create-a-conversation
You may need the user's user_id or id from the reference above to create a conversation. For those who are using MobileSDK or intercom_flutter, the id is not provided within the package or SDK. I found a workaround by using this Search for contacts API to get the id.

How to post with twitter API from client side

I am looking for a method to let the user:
sign in with twitter (I have setup this already)
post a tweet from my website
upon success, return the ID of the tweet
How can this be achieved?
The issue I see is that a user needs to setup a client id and so forth to automatize this (see: http://videlais.com/2015/02/28/how-to-create-a-basic-twitterbot-in-node-js-using-twit/)
Is there a way to bypass this by requesting the user one time read and write rights?

Can't submit anything to facebook page from facebook app

I now that this question was posted couple times but my problem is a little bit different. I try to submit for example event to my Page from Application.
I have private Profile on Facebook, Page and Application. Of course I'm admin of this page.
First thing I did was getting page access_token, so I went to https://developers.facebook.com/tools/explorer/ and in the URL I wrote /me/accounts/. Permission was set to manage_pages. I received access_token for my page.
Having access_token I connected my Application to the Page. So I made POST request to /[PAGE_ID]/tabs/ with app_id as a parameter and setting access_token of the Page. Now it's connected, I've checked it.
Now I try to submit some content by my Application. For example /[PAGE_ID]/events/ and passing parameters: name = Sample event, start_time = 2013-07-14T19:00:00-0700. And of course with the Application's access_token which I got by typing in the browser: https://graph.facebook.com/oauth/access_token?client_id=[APP_ID]&client_secret=[APP_SECRET]&grant_type=client_credentials. I got an error saying:
{
"error": {
"type": "Exception",
"message": "You must be an admin of the specified page to perform the requested action.",
"code": 1373019
}
}
I can post to this Page as a User but can't as an Application. My Application is of two types: Facebook Login and Facebook Tab. I've set permissions to publish_action and manage_pages publish_stream create_event.
What I did wrong?
Ok I solved the problem. Maybe it can be helpful for others. I don't know for what reason are those permissions https://developers.facebook.com/apps/[APP_ID]/permissions but the only thing I had to do was going to https://developers.facebook.com/tools/explorer/ and changing application from Graph API Explorer to my app and generating new access_token for privilages I needed. I don't know why they moved such crucial thing as permissions to the testing tool.

Facebook Request Dialog for single person

I am making a simple turn based board game on facebook. I plan to make a multiplayer mode where two player can play together like a duel mode. To do that, a person can send an app request to another person using facebook request dialog. But the user can select more that one person in that dialog. How do I make it send the request to only one person?
I could send to only one person using the graph API. But then, I need to get the target person's facebook id. I couldnt just 'prompt("Give me the user's facebook id")' for it. What the user need is a dialog where the user can select one of his friends, and return the facebook id. Is there such dialog in facebook? Or I will just need to make one.
You need to make one yourself.
Retrieve all friends through Graph API or FQL
Let the user choose one of them
Fire the Request Dialog with that specific friend's ID
i had the same question and landed here. I know that this is a old question but still people can and will find this.
So the right answer for me is:
FB.ui({method: 'apprequests',
message: 'My Great Request',
max_recipients : 1
}, requestCallback);
You can find this information at https://developers.facebook.com/docs/reference/dialogs/requests/
I hope I could help some developers
cheers.

Categories