I simply need to get the newest post from a specific Facebook page as a string in JavaScript for a website. I have never used the Facebook API and I'm still new to JavaScript, after many attempts I just can't figure out what the problem is...
So far this is everything I've done:
- Created a Facebook app, chose 'website' for the platform
- Inserted the JavaScript SDK code that I got from Facebook into my website code and replaced the placeholder 'appID' with the 'App ID' from my Facebook app
- Became admin to the Facebook Page
- On the Graph API Explorer page used the 'Get Token' dropdown to select 'Get Page Access Token', then selected the Facebook Page that shows up in the dropdown
- Used the following request in the Graph API Explorer: 'https://www.facebook.com/pagenamehere/?fields=posts.limit(1)' (The output provides the post I need but with some extra information like "create_time", "id", etc. that I will most likely remove in JavaScript unless there is a more precise request I can use instead since I only need "message")
- Copied the provided JavaScript code from 'Get Code' and inserted this under the JavaScript SDK code
- replaced '//Insert your code here' with 'alert (response)', the alert message is: [object Object]
Either I don't know how to obtain "message" from '[object Object]', or I'm not getting the response I need. I've tried to do this with the webpage on a live server.
Please help, I'm out of ideas and I've read the Facebook API too many times.
Thanks in advance.