Topic-icon javascript facebook api

Active Subscriptions:

None
7 years 6 months ago #60108 by fb_100000532508192
Hi what is the current method the load the jfbconnect js library. I'm using:
$jfbcLibrary = JFBCFactory::provider('facebook'); which pops up with an error. Also will a call like this work?
$jfbcLibrary->api('/me/likes/106444396111231', function(like_response) {
if (like_response.data) {
if (!isEmpty(like_response.data))
{
//alert('user likes page');
jQuery.fn.close_like_box();
}else{
//alert('user dosen\'t like page');
}
}else{
//alert('error with like might not have permission');
}
});
many thanks in advanced,
The topic has been locked.
Support Specialist
7 years 6 months ago #60127 by alzander
Replied by alzander on topic javascript facebook api
You're conflating the PHP and Javascript libraries.
$jfbcLibrary = JFBCFactory::provider('facebook');
This is PHP code that will get the JFBConnect's wrapper to the Facebook PHP library. This can't do any Javascript.

You could do that call in PHP if you want to load something from your server before the page renders, like:
<?php
$myLikes = JFBCFactory::provider('facebook')->client->api('/me/likes');
Note, in the facebook.php file, there is an api() function, but I'm bypassing that above and going straight to Facebook's PHP library. Our api call has a different parameter ordering from some of the original Facebook libraries. We haven't updated it, but using the code I show above helps map more 1:1 with Facebook's PHP examples.

As for Javascript, we don't 'wrap' the Facebook Javascript library, so you can call it directly. You'll just need to make sure you're doing it after the Facebook Javascript library has fully loaded, as noted in your previous post. So:

$jfbcLibrary->api('/me/likes/106444396111231', function(like_response)

Should be:
FB.api('/me/likes....
I hope that helps get you going!
Alex
The topic has been locked.