Facebook Graph API Events ticket_uri not working - facebook

When fetching a Facebook event from the Facebook Graph API, there is a field for the ticket_uri
The response always looks like this:
https://www.facebook.com/ajax/events/ticket.php?event_id=1461866457391623&source=12&ext=[aBigNumber]&hash=[randomhash]
which basically works in the current browser session, but does not work when saved and used somewhere else, like an other browser.
Is there a solution to redirect the user to the correct "Book now" url

That's the intended operation of that field - It's intended to be used by the current session user (i,e whose access token you're using) and contains a user/session specific hash which will expire -
If you want to link arbitrary other users (i.e. who aren't using your app) to the event for ticket purchasing reasons, the only alternative is to link them to the Event on Facebook.com and have them click it themselves

Related

Can I transform a user-id to PSID? - Facebook API Graph

Context: I'm building a webhook with NodeJS to get events from Facebook Page with my Facebook App. These events are: feed, mention (when a user tags the page on his wall) and message. I can get all events without problem. In all events I need to identify the user who write. When the users write a post or message in the page I get an ID (PSID) but when the user write a post on his wall tagging the page I can't get PSID, this is obvious because he isn't in the page scope. The only I get from this event is user-id from post-id.
I have tried the following:
I used this endpoint GET: /<user-id>/ids_for_pages as indicated in the documentation. This doesn't work for me because I would need that the pages are in my business administrator and this isn't possible because I need this webhook to manage many pages to many companies.
I used this endpoint GET: /<psid>?fields=name,id for events of type feed and messages (from Messenger) into the page but this gives me only PSID again.
Note: In my DB I save long-lived token of my page, ASID of the site owner and Page ID when my user does the login in the UI.
My questions:
Is possible transform user-id to PSID?
Can I get user-id through the PSID?
If you have a better idea to unify IDs when is the same user, I would like to know it. If this isn't possible I would also like know it.
My Goal: Each user event goes to the same case for the same user in my API, for this reason if the user is the same when tags the page and/or write a message in the page the idea is to identify him like same user and not like new case.

How to get post ID of Facebook shared URL, or how to get all posts shared via Facebook app?

Goal
My goal is for a user to share something he created on my site to Facebook, and for me to display all comments on my own page using the Facebook comments plugin.
So my ideal flow would be:
User creates content with example id vjrjf834fdkfj, and shares using public URL http://example.com/vjrjf834fdkfj/.
User shares this URL on Facebook via my Facebook app ID. The post ID is 1234567.
I get this post ID. (This is what I need help with)
I store this in my database.
Whenever a visitor visit the page http://example.com/vjrjf834fdkfj/ I look up in the database what the post ID is (1234567 in this example), and call the Facebook comments plugin using this post ID.
What I tried
Attempt #1
First failed attempt: read the post_id field of the FB.ui callback but this response is typically empty because Facebook says that:
Only available if the user is logged into your app using Facebook and
has granted publish_actions. If present, this is the ID of the
published Open Graph story.
My user is not always logged into my app via Facebook, because he can also create a normal account.
Attempt #2
So my next attempt was to get a list of all posts of this app by calling the Graph API. I have a "basic" app with the "Website" platform set to my website URL (www.example.com). Given this list I might filter this on the relevant URL and voila, get the post ID for the right URL.
I can create an access token and call https://graph.facebook.com/v2.8/{app-id}/objects?access_token={token}, but this gives an error The parameter type is required. And when I try to get a list of object types by calling the /object_types endpoint, I get an empty list.
Attempt #3
I also played a bit with creating a Page Tab but the documentation makes no sense to me as to how that would apply to my case. I ended up with two extra pages, all empty, and not what I want. However, I could live with an extra page on my Facebook page showing a list of all posts that have been shared (so these posts would appear here and on my user's timeline).
Questions
So:
Why is this object_types list empty? I expect that something like "post" would show up here, allowing me to get a list of all posts associated with this app ID.
If this is not possible, how can I still achieve my end goal?
Thanks.

Implementing metatags for open graph

Facebook needs the url of the object when sending a action post request. Now , my app only allows authorized users, I redirect the user to the login page and it redirects back to the user requested page.
But how do I differentiate between fb trying to access the metatags(while posting) or users coming from fb whom I have to redirect ?
You missed some concepts behind of OpenGraph. All objects should have a publicly accessible representing page.
Citing Publishing Objects section from Facebook's OpenGraph Objects documentation:
Open Graph Objects are simply your web pages with Open Graph meta tags. Before you can publish an Open Graph object, you must define its corresponding object type in the Open Graph section of the Developer App. Once you have defined your object type in the tool, you must create a publicly accessible web page that represents your object using Open Graph metatags. We provide boilerplate metatags that you can use to create this web page in the Developer App (click the Get Code link next to your object definition). With these tags in place, you can publish actions that refer to your object.
When Facebook sees the first action applied to your object, we will scrape your page, read its meta tags and connect the user to your object, via the action. Every 7 days after the initial scrape of your object, we will attempt to re-scrape your object to keep the object data up to date.
The problem was to differentiate between a Facebook crawler and a user.
I don't remember the exact thing I wrote, but the general idea was that facebook parser just reads the html head tags . I added a fb redirect which sends the authenticated user to the desired page . This redirect wouldnt affect the crawler because javascript isnt executed by a crawler.
Now , since my need was to allow only authenticated users to go ahead, the FB js api handled auth as well. :)
Do tell me , if you need to know the specific fb api call.

Facebook requests - how to pass through custom variables from the Requests page

I am building a facebook app that has a send to friend feature in it.
Each user is given a specific userkey that identifies them and them alone.
So Person A invites person B.
So when person B gets the invite, when they click ACCEPT, we pass the referrer userkey in the URL…
e.g. http://mydomain.com.au/return_user.aspx?referrerkey=iuahsduiahsdfuiha
So when person B has already installed the fb app, the referrerkey variables is passed back to our site, so we can manage the link between the 2 users there.
However if person B hasn’t added the app. And Person B clicks the ACCEPT button on the invites page the user has to be take through the “Allow Access” page, from there, they are directed back to the APP home page, with none of the variables I need. E.g. the referrerkey.
So how can i get this to work for both users that have already added the app and havent added the app?
Yes, the request 2.0 flow will always land the user back on the canvas home page- no avoiding that.
When you create the request, though, you can add "data" parameter to the request object, and put whatever data in it you want. Then, on your canvas' home page, query for data in the signed_request. Setup a variable like, user_id or some app specific variable, game # or something. If it's present, then redirect to a more applicable page or route.
You can identify entries to your app- differentiating it by other non-request redirects to our canvas home page-- because there will be request_ids present in signed_request.
Note, you can also take the request id, and get the object from Facebook, which will have the "from" referrer. So you don't need to pass that around.
Assuming you're using the PHP facebook SDK and a canvas app, You're probably using require_login() to redirect the user to the auth screen. By default, the auth screen will send the user back to the canvas URL you set in the app settings.
To get around this, pass a GET parameter called "next" with a urlencoded URL as the value. If you're lucky, your version of the facebook SDK may have this code preset but not active. Look for ‘&next=‘ in the Facebook class.
The only option I know of is making adding the app and linking with friends two separate processes.

Editing a User's Likes on Facebook

I've been looking at the Facebook API to find some way to edit a user's Likes (that is, add or remove items from https://graph.facebook.com/me/likes/). The API doesn't say anything about it specifically, but does say this:
You can publish to the Facebook graph by issuing HTTP POST requests to the appropriate connection URLs above.
Where above, one of the connection URLs is the aforementioned https://graph.facebook.com/me/likes link. However, there's no documentation for the PROFILE_ID/likes post, and whenever I try to post it returns the error "invalid post_id".
I assume this is because to like something, you post a request to POST_ID/likes. It's a bit inconsistent. What I'm trying to do is get the user's profile to add a Page to their likes (by posting using the page's id as an "id" parameter in the post body). However, it seems like there's just no way to edit user's likes.
At the end of the day, I just want to allow a user to click a button in my application (mobile device application, not a web app) and have them add our Facebook page into their list of pages, and I've found no way of doing that short of presenting our page to them and making them click on the "Like" button manually. Many other things are supported without showing the Facebook website, like posting to their wall or making albums, but I can't find anything to do this.
Any ideas?
Looks like I can't. Not in the way I want to anyway.