i am starting to build a facebook extension app. i got the api auth part working.
now as i request anything using the javascript api, i am unable to.
for example:
<div id="profile_pics"></div>
<script type="text/javascript">
var widget_div = document.getElementById("profile_pics");
FB.ensureInit(function () {
FB.Facebook.get_sessionState().waitUntilReady(function() {
FB.Facebook.apiClient.friends_get(null, function(result) {
var markup = "";
var num_friends = result ? Math.min(5, result.length) : 0;
if (num_friends > 0) {
for (var i=0; i<num_friends; i++) {
markup +=
'<fb:profile-pic size="square" uid="'+result[i]+'" facebook-logo="true"></fb:profile-pic>';
}
}
widget_div.innerHTML = markup;
FB.XFBML.Host.parseDomElement(widget_div);
});
});
});
</script>
the above sample code should display square thumbnail images of my friends. it just shows square thumbs (BLANKS) with the facebook logo over it. where am i going wrong?
FYI:
i have the files located in the localhost. in the facebook application settings, i gave the connect url as the address of the ‘localhost/dir/index.html’ url. is there something i am doing wrong?
please help me out.
EDIT
this the code i am using to make login:
<script type="text/javascript">
//<![CDATA[
var api_key = 'myapikey';
var channel_path = '/xd_receiver.htm';
FB_RequireFeatures(["Api"],
function(){
// Create an ApiClient object, passing app's API key and
// a site relative URL to xd_receiver.htm
FB.Facebook.init(api_key, channel_path);
var api = FB.Facebook.apiClient; // require user to login
api.requireLogin(function(exception)
{
FB.FBDebug.logLevel=1;
FB.FBDebug.dump("Current user id is " + api.get_session().uid);
// Get friends list
//5-14-09: this code below is broken, correct code follows //
//api.friends_get(null, function(result){
// Debug.dump(result, 'friendsResult from non-batch execution ');
// });
api.friends_get(new Array(), function(result, exception){
FB.FBDebug.dump(result, 'friendsResult from non-batch execution ');
});
});
});
//]]>
The sample code you posted works fine… I just tested it in one of my devel FB apps and it created profile pictures of my friends.
You might want to throw a
console.log(result)into your code and examine the results of the API call with Firebug. Perhaps it will have an error message for you. It sounds to me like there could be an issue here, because anfb:profile-piccreated without a validuidwould show a blank square.I would double-check that the URL you gave the application under the “Connect URL” setting is a valid URL that Facebook can reach. Also double-check that the path you gave for the xd_reciever.htm file is working. A third thing worth double-checking is that you have the correct xml namespace set on your document: