Hi,
I am very new to Facebook integration and have hit a wall which I hope someone can help me with. I have read through many articles and tested various code samples to achieve what I need and I think the nearest I can get is FQL and JavaScript.
Basically I need to retrieve data from a Facebook table and present the results in a html page as a recordset, so it will probably be more than one row of results to be returned.
I have this working when querying a single item when something is = to something, the single result is printed to screen in my html page but when I alter the query so that it returns more than one result the code seems to be failing without any errors.
Here is an example query I am trying to get working in the sample javascript code below but it returns a javascript error. I know the query is good because it can be tested here.
Test page for FQL SQL queries
example query SELECT name, pic_square, profile_url FROM user WHERE contains('sam roberts')
Error when above query repalces query in working example below.
SCRIPT1006: Expected ')' facebook_2.html, line 29 character 95
Here is my working example that retrieves just a single row of data, you can run this but it needs to be on a web server.If you have any advice please let me know, I really need it to work in JavaScript as this is the only language I have experience in.
Thanks for looking
I am very new to Facebook integration and have hit a wall which I hope someone can help me with. I have read through many articles and tested various code samples to achieve what I need and I think the nearest I can get is FQL and JavaScript.
Basically I need to retrieve data from a Facebook table and present the results in a html page as a recordset, so it will probably be more than one row of results to be returned.
I have this working when querying a single item when something is = to something, the single result is printed to screen in my html page but when I alter the query so that it returns more than one result the code seems to be failing without any errors.
Here is an example query I am trying to get working in the sample javascript code below but it returns a javascript error. I know the query is good because it can be tested here.
Test page for FQL SQL queries
example query SELECT name, pic_square, profile_url FROM user WHERE contains('sam roberts')
Error when above query repalces query in working example below.
SCRIPT1006: Expected ')' facebook_2.html, line 29 character 95
Here is my working example that retrieves just a single row of data, you can run this but it needs to be on a web server.If you have any advice please let me know, I really need it to work in JavaScript as this is the only language I have experience in.
Code:
<html>
<head>
<title>My Facebook Login Page</title>
</head>
<body>
<div id="msg"></div>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxx',
status : true,
cookie : true,
xfbml : true
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<script>
function doSomething()
{
FB.init({appId: 'xxxxxxxxxx', status: true, cookie: true, xfbml: true});
var query = FB.Data.query('select name, uid from user where uid=742375122');
query.wait(function(rows)
{
document.getElementById('msg').innerHTML = 'name is ' + rows[0].name;
});
}
</script>
<input type="button" value="Click here" onClick="doSomething()">
</body>
</html>
Thanks for looking