Just started working with the Facebook graph api and have hit abit of a wall. I want to access facebook pages by using the api /events/ however i have discovered that this requires an access token, IE a login. (at least thats how i think works)
Basically my site lists bands and events, so id like the user (band) to specify a connection to their facebook page if they have one (pageId) so i can dynamically pull the events they have posted to their facebook page.
Is this even at all possible? at the moment i am able to pull in the pages feed like /feed/ but running /events/ throws an excpetion saying it requires an access token.
Im using PHP with a fresh install of codeigniter 2.0 its also worth mentioning im using elliot haughins facebook library facebook library though this isnt essential to my project
You can register an app with facebook and it can have it's own token that you can use to access the event for pages. You can find out how to get an app token here. http://developers.facebook.com/docs/authentication/
Hope that helps.
Related
I apologize in advance if this question is horrible.
My goal is to have my website grab data (events) from one specific facebook page that I own, and then display that data on the appropriate website.
I'm new to the facebook graph API. I downloaded and set up the PHP SDK to use on my website.
I created the initial $fb object as it stated to do within the SDK "Getting Started" page.
However, the next step in the system is creating a way for users to "login" and with this it generates the required access token.
On my site, I have absolutely no reason to have a user login.
I am so lost, that I am not even sure what to ask.
I guess, what do I have to do so that I can get an authorization token that will grab public data, without having the visitors to the website authorize an app or login.
I have searched a lot over the last few hours, but the only thing i can find is the document on how to have users log in to get the access token.
Any answer or documentation linked would be so greatly appreciated. thank you.
I searched in Stack Overflow, Google, etc, but I can't figure out how to show my stuff from my Facebook on my website. I tried some solutions and each one prompted the login dialog and visitors had to log in and accept my application (I've created one to test).
Many answers here were too generic, I didn't understand them that is why I'm asking.
I want something that would let my website "log in" to Facebook and show my status or photos to visitors without them needing to accept an app or log in into Facebook with their account.
I tried a facebook-php-sdk example with my AppID and AppSecret and it asked me to log in.
Also, github.com/facebook doesn't have an SDK for Python similar to facebook-php-sdk
You could write a script (eg. using the FB PHP SDK) that uses a long-lived access token to fetch your FB data and then store the data in your backend database (or other store for your website). To Facebook, your script will look like an app and your machine will be the only 'user' of that app. Note, long-lived access tokens are good for 60 days max. You could also try using an App Access Token to fetch basic info. App Access Tokens don't expire.
This might not be exactly what you are looking for since you posted this with the php and python tag, but it might solve your problem.
If you're website is powered by the wordpress engine you can use If-this-then-that : https://ifttt.com/
It basically allows you to create "recipes" with something like:
if new status on Facebook then create post on wordpress
The post will not require others to log in to Facebook.
This is without writing a single line of code only a couple of mouse clicks. So I'm not sure if this satisfies your needs.
I need to grab the statuses from a Facebook page via PHP to display on the page. I don't want to have people logging in to facebook just for my script to grab the statuses from the page since it is a public page and isn't restricted. I have the Facebook API for PHP in my projects directory but have no idea how to use it to do what I want it to. Could someone give me a code example of how I'd do this? Thanks!
It's really a straight forward task if you follow the documentation. Since /PAGE_ID/feed requires any valid access_token, your app access_token is enough to get the data:
Open the Graph API Explorer (I'm querying coca-cola/feed)
Get an app access_token from the Access Token Tool and use it instead of yours
You're done!
Last December, I set up an app for a client who wanted to pull their public facebook posts into the footer of their website.
I was using this URL to pull the message, create time and permalink and when I wrote it, all was good:
http://api.facebook.com/method/fql.query?query=SELECT%20message,%20created_time,%20permalink%20FROM%20stream%20WHERE%20source_id=138631878804%20AND%20message%3C%3E%27%27%20limit%203
Today they reported that it was no longer pulling their information. I put that url into a browser and the result is "Requires valid signature"
I've gathered from google that I need something called an access_token, also I've seen where I can use the php sdk but then I need an appId and a secret token.
At this point, I've read so many different sources that I am thoroughly confused. The FQL query above represents the full extent of my Facebook programming experience. It looks like maybe I want the Graph API, but I don't want anyone to have to sign into anything.
Can one of you guys who are more versed in the voodoo of facebook nudge me in the right direction to do this:
From PHP, pull public messages from the stream table without forcing a user to log into facebook.
Thanks!!
To pull posts from a publicly visible Page on Facebook, you can use any valid access token. For most sites managing a page, this will be a page access token retrieved via one of the page's admins authorising your app to have access to their pages, but that might be overkill for your use-case.
Probably the quickest solution is to just create a new App ID for the site, get the app access token for that App (see 'App Login' on https://developers.facebook.com/docs/authentication/ ) and then use that access token to retrieve the posts.
I found several links all from a simple Google search.
Duplicate question: https://stackoverflow.com/questions/3298836/how-you-get-access-tokens-for-facebook
http://benbiddington.wordpress.com/2010/04/23/facebook-graph-api-getting-access-tokens/
https://developers.facebook.com/docs/authentication/
I'm developing a site for a client who already have the photos of his products on Facebook, and he wants the same albums to be replicated over his site. I was already using Facebook Connect, so I dropped a combination of photos.getAlbums and photos.get to dynamically make the galleries.
So far so good, but then I realized that if there's no user logged trough FBC, no session is created and the API becomes unusable, even for content that is publicly available. I obviously want to show the albums to everyone and not just the people who connect their accounts.
Is this how all functions in the Facebook API work? What's the best (easier to implement) workaround for this situation?
As of September 2010, you can now authenticate just as an application, with no associated user. See http://developers.facebook.com/docs/authentication/ for details. Or you can run this example code to get an access token:
curl -F grant_type=client_credentials \
-F client_id=your_app_id \
-F client_secret=your_app_secret \
https://graph.facebook.com/oauth/access_token
For the record, I managed to solve this situation by developing a small backend that requires the client to login to Facebook once and give offline_access extended permission to the FB app, so I can save his session key and use it to authenticate the Facebook API client every time I need to use FQL to get non-public content.
One could obviously add some caching in the middle to avoid unnecessary requests to Facebook, but it's been working fine for months now without hitting any limits that I know of.
That doesn't make sense to me - I have a (relatively simple) app that renders in facebook even if the user has never logged into facebook before (in which case it displays demo data).
When using the facebook PHP library, I just do this:
$facebook = new Facebook($api_key, $secret);
No session id required - but, obviously, api functions that depend on information about the user aren't going to work.
You can also look into an "infinite session" for your app - you could create an infinite session key for yourself and use that session to access the API.