FB user button onClick event attend [duplicate] - facebook-graph-api

I would like to make possibility for attending to event in Facebook feed view in my app. Is it possible by POST-request of Graph API?

IF it´s still possible, then by just doing a POST request to the attending endpoint. For example, with the JS SDK:
FB.api('/[event-id]/attending', 'POST', function(response){
console.log(response)
});
Afaik it was possible earlier, and you would need the rsvp_event permission for this.
Edit: I just tried it in the API Explorer, it definitely works: https://developers.facebook.com/tools/explorer/?method=POST&path=[event-id]%2Fattending&version=v2.5 (of course you need to replace the event ID)

Related

Facebook SDK edge.create is deprecated. Any alternative?

edge.create and edge.remove JS SDK Events are deprecated. Is there any alternative to allows users to subscribe to the like happening event (fired when the like action is completed)? I've not found any webhooks to replace the callback function I used before deprecation:
FB.Event.subscribe('edge.create', function(response) {
// like clicked
});
edge.create and edge.remove JS SDK Events: These Events will no longer
be accessible. As an alternative, you can use our Webhooks and be
notified every time someone likes one of your Facebook Pages.
For more information
Facebook Offical

Facebook Messenger Chatbot Custom Event Tracking

I am trying to log custom events with a Facebook Chatbot I have developed, however I cannot for the life of me find a reference for the custom_events types.
The example listed on their reference shows fb_mobile_purchase as a custom eventName. I don't want that, and I can't find anywhere that lists other types.
I want to be able to track when the chatbot sends the user a specific message, but just setting the eventName to anything results in an event name in the Analytics as Reserved5.
Is there a reference to eventNames anywhere within Facebook Documentation?
You could consider using Chatbase for bot analytics (free to use), which has a Custom Events API.
Currently the docs give this as an example request:
var request = require('request');
request.post({
url : "https://graph.facebook.com/<app_id>/activities",
form: {
event: 'CUSTOM_APP_EVENTS',
custom_events: JSON.stringify([{
_eventName: "fb_mobile_purchase",
_valueToSum: 55.22,
_fb_currency: 'USD'
}]),
advertiser_tracking_enabled: 0,
application_tracking_enabled: 0,
extinfo: JSON.stringify(['mb1']),
page_id: <page_id>,
page_scoped_user_id: recipientId
}
}, function(err,httpResponse,body){
console.error(err);
console.log(httpResponse.statusCode);
console.log(body);
});
So, when the bot is sending that specific message you want to keep an eye out for, fire that message but with a different _eventName, and if needed other parameters.
Keep in mind, by recipientId they mean the PSID of the user the bot is sending the message to.

Communicating over Messenger on behalf of another user's page

I want to make a Messenger bot with Messenger platform. But this bot needs to be connected to other Facebook users' pages, not my own page. I have a Facebook app with Messenger configured. I want to let other Facebook users who are page owners to give my application a permission to post on behalf of their pages through Messenger, as well as receive messages from their pages on my app's webhook.
The Messenger Platform docs only explain how to post on behalf of your own page.
Is is possible to make this through Graph API + Messenger Platform or something else? And maybe with a few pointers how?
This is how I send my messages:
uri: 'https://graph.facebook.com/v2.6/me/messages',
qs: { access_token: PAGE_ACCESS_TOKEN },
method: 'POST',
json: messageData
So I think if you would just need them to supply you with their page access token, and then you could send messages as their page through your bot.
EDIT: I guess this only answers how to send messages as them. To receive messages too you'd need to somehow subscribe your webhook to their page, which I think you need to be an admin of to do, so I'm not sure receiving their pages messages is possible through a straightforward system like what I'm suggesting. There may be other more complex workarounds though.
EDIT2: Maybe you can give them your webhook URL and have them verify and subscribe it for you

Adding Custom action links next to 'like' and 'comment' for an Open graph publish action

I've created Opengraph objects and actions in my app, and I'm able to post an action so that it shows up on the various channels. However, an important feature I need is that with these posts, I'd like a custom action link to appear along side the comment and like links at the bottom of the post. My assumption / understanding was that if I posted a user's action on an object in my website, the other actions that were designed to act on that object should also show. Do I have to manually connect the other actions to the object somehow?
I've tried adding the 'actions' parameter to the post data and specifying the name and link for the action but it doesn't seem to work. This does however work if I'm posting just a message to /me/feed and I can see the custom action link.
So this:
function publish() {
var publish = {
actions : [{
name : 'Custom Action',
link : action_url
}]};
FB.api('/me/appns:action&object='+object_url,'post', publish, function(response) {
if (!response || response.error) {
alert('Error occured:'+response.error);
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
This works as far as publishing the action on the channels, but the Custom Action link is missing.
However, if I convert this to a plain old feed post using FB.api('me/feed', 'post', publish ....) I do see the custom action link.
Am I expecting something to work that's not in FB's current feature set?
Thanks in advance for the help!
this feature is currently not supported when posting Custom Open Graph actions. We're in the process of implementing it and will be sure to announce it and add it to the documentation at developers.facebook.com/docs when it is ready. ETA is 1-2 months.

How to edit an existing event using the Facebook Graph API

I've done extensive research on this, and am baffled. Similar questions on stackoverflow have been answered with, in in short: RTFM. Well, I've done that, and more, and I still can't find how to do this.
On the main FB Graph API page, documentation is given for authenticating, reading, publishing (creating), deleting Graph objects, but I don't see modifying anywhere.
The FB Graph API > User page gives description only of how to create and delete an event on behalf of an authenticated user. I've had no problem with these two actions.
The FB Graph API > Event tells you how to retrieve an existing event, as well as publish to the existing event, posts, links, feed, etc. Once again, no help with modifying.
I've tried (desperately) (':'s removed intentionally due to hyperlink limit):
Sending the same POST request as creating event, ie to https//graph.facebook.com/<user_id>/events, but with an extra 'id' parameter--the existing facebook event id. Facebook doesn't like that, gives me an 'id parameter already sent' error (I'm assuming the user's id).
POSTing to the event directly ie to https//graph.facebook.com/<fb_event_id>/ using the same auth_token as was used to create it. 'Post unsupported' error message.
The fields I send along with the POST are the same as those when creating the event-- 'name', 'location' etc.
If someone's been able to do this, one simple POST example would clear everything up for me.
Thanks!
UPDATE I started using the PHP SDK, but lack of examples disheartening. In hopes that this will save someone else frustration Here are doc examples augmented with an actual api call example:
"You can create an event for a user by issuing an HTTP POST request to
PROFILE_ID/events with the create_event permissions and the following
parameters."
$facebook->api('/'.$profile_id.'/events', 'POST', $params);
Normal enough ... but edit event docs (as of 12/7/12) are misleading:
"You can edit an event by issuing an HTTP POST to /EVENT_ID with the
create_event permission. "
$facebook->api('/events/'.$eventid, 'POST', $params);
Brian
I was able to update a page event by using a POST (not a PUT) directly to the event, using the account or page authentication token. It sounds exactly like what you did in 2 above.
curl -F 'access_token=...' \
-F 'name=A modified event name.' \
https://graph.facebook.com/event_id
I would suggest that you try just sending a modified name field. Also, because you have already created the event, you have the correct permissions. For those who don't know, you need the extended permissions of offline_access, create_event, manage_pages, etc.
It is frustrating, because at one time there was documentation on updates on the Facebook site, but now I can't find it.
Updating is the same as creating BUT, you can only update events created by your APP ID..