Reputation:
I've tried and tried to get Open Graph to work on my own without any luck. I've also tried alternative options such as ajax call works in Chrome, Firefox but not in IE?, but that has serious issues.
What I would like is a complete solution for using Open Graph to retrieve all wall posts given a specified Facebook profile ID. It needs to get the access token without having the user login to facebook. edit: I have an application with an App ID and App Secret. Shouldn't I be able to use this to get the Access_token? I want users without a facebook account to be able to see the wall posts of this kids page (that's kind of the whole point of building a separate site).
For what it's worth, this is for a site for a kid with a terminal brain tumor... which kind of leaves me in a position where I can't make demands (like spend $50 on an SSL or "just use facebook").
edit I think the only thing I need is to get the access_token. This can't be that difficult.
Upvotes: 0
Views: 2680
Reputation: 31173
- NOTE: this answer both your questions and peraph someone should close at least one of them
so my solution to this problem is simple; you still continue to use AJAX to perform the request to facebook but not directly.
so your code will look something like this:
$(function() {
$.ajax({
url : 'ajax-handler.php',
data : 'action=get_access_token',
type : 'GET',
dataType : 'json',
success : function(json) {
}
});
});
then on the ajax-handler.php
file you will put all the stuff needed to retrieve the access_token
and other information.
a server-side pseudo code (i'm using php here) will look something like this, but you need to use the php sdk for a better coding...
<?php
$action = $_GET['action'];
if (isset($action)) {
switch($action) {
case 'get_access_token' :
$query = array('client_id' => '####', 'client_secret' => '####', 'grant_type' => 'client_credentials');
$access_token = file_get_contents('https://graph.facebook.com/oauth/access_token?' . http_build_query($query));
//$access_token will be like access_token=asdas8dd98sada...
//but we don't use it here...
$app = file_get_contents('https://graph.facebook.com/######');
echo $app;
break;
}
}
?>
and this is the result:
- demo: http://bit.ly/JO59mO
Upvotes: 2
Reputation: 1155
I do not have a turn-key solution (sorry not enough time), but I can offer a way to get around cross-domain requests:
easyXDM is a Javascript library that enables you as a developer to easily work around the limitation set in place by the Same Origin Policy, in turn making it easy to communicate and expose javascript API’s across domain boundaries.
Example: http://easyxdm.net/wp/2010/03/17/cross-domain-ajax/
Upvotes: 1
Reputation: 6484
Is your facebook account friends with his account? If so, you can generate your own access token for your own account and view the kid's feed using your own token using https://graph.facebook.com/id-or-alias/feed
Upvotes: 0
Reputation: 6620
Only public data on the Graph can be accessed without a valid Access Token. A list of these available public arrays can be found here. A user's wall post's can be viewed using the /me/feed
API Call, but this action specifically requires an access token.
Upvotes: -1