views:

391

answers:

3

I have downloaded php-sdk for using facebook in php. I also created facebook application in the facebook web page in order to get API key and secret key.
When I run example.php and try to connect to facebook it shows me the following error:

Configuration errors: To fix this error, please set your Connect URL in the application settings editor. Once it has been set, users will be redirected to that URL instead of this page after logging in.


I am using this php-sdk in the localhost. I tried to assign localhost as Connect URL but facebook doesn't accept it. I have read about Cross Domain Communication Channel and think this is what I need. But I don't know how to use it.
Anyone can help me to solve this problem please?


Update Actually what I need is following. I have Web Application and need to connect to facebook and search for users in facebook who has specific(user will specify this) Likes and Interests. Any idea about solving my problem?

+3  A: 

What about setting up DynDNS to your IP address, and using that as a testing server? DynDNS will give you a free sub-domain that displays your page, and has tools to keep the domain up-to-date with your IP address.

John
+2  A: 

The problem with using localhost as the connect url is that facebook cannot access it, localhost is for your local machine and for facebook to connect to your computer you will need some sort of domain service to allow it to connect and then proper settings on your router to allow the communication to come through.

I would recommend setting it up on a web host and trying to use the sdk from there.

A good place to start when working with the facebook api would be to check out a tutorial on the Open Graph, one I found useful for my application that get all of a users friends was this: Facebook Connect Tutorial

Kieran Andrews
+1  A: 

To search people based upon likes or interests, use the new Graph API, and parse the JSON.

For instance, this will search for anyone with an interest in Cheese:

https://graph.facebook.com/search?q=Cheese&type=user&access_token=YOURTOKEN

This way you don't need any authentication, just an access token.

The resulting PHP code would be something like:

$accessToken = 'abcdefghijk';
$query = urlencode($_GET['q']);
$graphUrl = 'https://graph.facebook.com/search?type=user&accessToken=' . $accessToken . '&q=' . $query;
$results = json_decode(file_get_contents($graphUrl));

I'm off for a slice of Camembert.

Kevin Sedgley
Bakhtiyor
Now it works, why I inserted **access_token** variable in the url.
Bakhtiyor
Yes, you will need `access_token` for this; I've edited my post to explicitly say this.
Kevin Sedgley
Is there any rules to generate that access_token value? Because when I assign some random value it doesn't accept it. How to generate it?
Bakhtiyor
Bakhtiyor
I don't know but I am getting this error message { "error": { "type": "OAuthAccessTokenException", "message": "An access token is required to request this resource." }}
Bakhtiyor