Is it possible to check from where user came to my facebook application? I'm looking for something similar to $_SERVER["HTTP_REFERER"]. My facebook application is written in PHP.
No, since facebook "proxies" every request to your app, you will never see a referer.
The only thing you could do would be handing out self generated referer-urls.
Just apply the GET parameter app_data to your url - this gets passed directly through to your app with the signed request.
This would be a method of tracking how many visitors come from sources you know and made a link deal, for example.
Related
I have a website I'm working on. It enables users to register and post stuffs within the site. Can I get a link to some sort of api that allows people to add their facebook account (once) and then automatically post what they posted on my site on their facebook newsfeed (the sort of thing that happens when you connect your facebook account to your twitter account) .I've searched and can't seem to get exactly what I want
What you want is pretty common and if you searched you clearly didn't do a good job on the search.
Using the Facebook PHP SDK is pretty straight forward. There is a PHP Library available with a demo of the functionality you want. In your case you need to do some stuff more, so I'll explain globally what you should do:
Get the Facebook PHP SDK and load it into your website, determine what scope you need to perform the actions what you are going to do, in your case you need to have access to their timeline which is called the publish_stream scope. In order to get the Facebook PHP SDK working you need to create an app at http://developers.facebook.com
If a user grants access you need to save the authentication token that the user provides and save it in your database for later use. I'm not 100% sure how long they are valid, I think it's maximum of 30 days at the moment, but you have the ability to refresh the toking in the requests you make (correct me if I'm wrong, it's been a while..)
Everytime an action is done using the Facebook API you inject the usertoken in the request, thus performing the "post" action onto their timeline.
What you are looking for is pretty straight forward and easy to find..
i am having trouble accessing the wall of a user. I am making a request to 'https://graph.facebook.com/'.$userID.'me/feed?access_token='.$access_token
where $access_token contains my access_token.
the strange part is that it is working well when I make the request from the application page... that is: http://apps.facebook.com/myapplication/ but when i make the same request in my callback script, it returns only those posts which are made by some application, and it does not show user's own posts like, status messages etc.
Try using the new PHP SDK, i've seen people solving bugs like yours just by changing to the SDK. It usually doesn't require you to pass the access token and supports all methods of the API (i think).
With /me/feed you can access the feed of the currently logged in user. To get the feed of some other user, you need to use their id. I am assuming that's the reason why its working in the application page and not in the script.
I've been building a web app that uses facebook integration for easier registration/login and notifications for the users. However, for the notifications I want to be able to post to a users facebook wall when something happens on our site.
Really I see two possible problems with doing this. First being that the user will most likely not be logged in to our website when the notification needs to happen. Second I have not found a way to post to the feed using any identity other than the current logged in user.
So to reiterate exactly what I'm trying to do. When some action takes place on my site involving Bob, I want the websites application to post on Bobs wall notifying him of the action as if the application is one of Bobs friends. From some of the things I've seen while researching this, it seems as if facebook might not treat applications like users and I might have to go through a page to accomplish what I want. But really I'm ok with that.
What you need to do is to ask for the offline_access permission. Then you can store their graph id property after they login/authorize to your site's database. Then you just post to that graph id instead of instead of /me. In your case you would then POST a request to the "$user_graph_id/feed" endpoint with whatever parameters you usually have.
I've been playing around with the Facebook PHP SDK for a site that I'd like to use Facebook's single sign in for. I've been able to login to my Facebook account from my site and successfully tested a few of the features (posting to /me, an FQL query etc.).
When generating the login URL I have set the cookie parameter to true, however I seem unable to establish a persistent session with Facebook. At the moment the Facebook login window redirects the whole website (I have not yet tested this within the webpage or a popup). The user can authorise and is returned to my site, but the session data is stored in a query string on the return URL. If this string is removed the user must reauthenticate.
Previously I have worked with the JS SDK and this has not been an issue. It's worth noting in this case that I am avoiding using the FBJS (because I believe the PHP SDK is an alternative) and FBML (because it is deprecated) - I also have not implemented a cross domain communication file as this appears to be unnecessary.
I have read about conducting the authentication within an iFrame. I'm unable to find any documentation about this though.
I have considered storing the $_GET querystring in a session on my site and appending it to the website URL, or an iFrame URL, when I need to authenticate. I'm certain that this is the incorrect way to achieve what I'd like though.
Please could someone point me in the direction of some documentation regarding this. Perhaps I am mistaken in thinking I can do this without JS, or maybe I need to manually set up the session cookie? I've searched at length but have been unable to find any documentation that describes this specifically.
Thanks for any help!
Hello I am looking to build a basic API and application/apps system on my social network something like Facebook or other sites have, my site is in php/mysql. Here are some questions.
1)
Basically what I want to do is give a user a API key and secret. After I have these how can I use them in my php app to authenticate a user request which would come from there server?
2)
I can basically build an API to send a request to my server with CURL and get the result back to the page in XML or JSON or whatever, the problem is when sending the request the user would have to know the user ID they want to send to lookup data against, this is fine for an API but I am wanting to have an Apps section where the user's app site would be using the API and would be loaded into my site in the app section with an iframe, the problem is, I need to find a good way to make it where a logged in user on my site can go to the app section and go to an app and there username should be available to that page loaded in the iframe. Facebook and myspace do this somehow and many other sites; I am lost how to get around this hurdle.
Any help on any of this is really appreciated, thank you
Update:
I just had an idea, if I require a cookie to be set when a user visit's my site, then they would have a cookie and it could hold there User ID, then my API script could look for that cookie to exist and grab it's value?
If you plane on using an IFRAME, then no, your API hosted on a separate website (the website inside the IFRAME) would not be able to grab the cookie. The cookie is only visible on the website that it was set for.
I have only used Facebook API with the FBML (not the IFRAME,) but all they do their is basically replace what's in the page with the info that the "tag" is calling. I'm not sure if there is a better way, but you could possibly call a page on the app's server (say the app is hosted at http://example.com/app/, and you called http://example.com/app/?id=28318&name=John%20Maguire,) and have your API code handle it and turn it into a variable?
Maybe you should look into the source code of the Facebook API client.