Embedding the Facebook Third-party User ID
To function properly, Applifier’s tools need to know the user’s third-party ID provided by Facebook, which is passed to us via the thirdPartyId parameter. This information is available via the Facebook Graph API and is supported by numerous client libraries. Read more about using the third party ID on Facebook’s developer blog here.
Example in PHP
<?php
require_once 'facebook.php';
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
'cookie' => true,
));
//if authorized
if ($facebook->getSession()) {
$info = $facebook->api('/me?fields=third_party_id');
$third_party_id = $info['third_party_id'];
}
?>
<script type="text/javascript">
(function() {
window.applifierAsyncInit = function() {
Applifier.init({applicationId: YOUR_APPLICATION_ID, thirdPartyId: "<?php echo $third_party_id ?>"});
};
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
a.src = (('https:' == document.location.protocol) ? 'https://secure' : 'http://cdn') + '.applifier.com/applifier.min.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(a, s);
})();
</script>
Example in JavaScript
<script type="text/javascript">
(function() {
window.applifierAsyncInit = function() {
FB.api('/me?fields=third_party_id', function(response) {
if (response != undefined && response.third_party_id != undefined) {
Applifier.init({applicationId: YOUR_APPLICATION_ID, thirdPartyId: response.third_party_id});
}
});
};
var a = document.createElement('script');
a.type = 'text/javascript';
a.async = true;
a.src = (('https:' == document.location.protocol) ? 'https://secure' : 'http://cdn') + '.applifier.com/applifier.min.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(a, s); })();
</script>
Example in Ruby
In your application controller:
before_filter :require_facebook_login current_fb_user_id = fbsession.session_user_id response = fbsession.users_getInfo(:uids => [current_fb_user_id], :fields => ["third_party_id"]) users = response.user_list third_party_id = users[0].third_party_id
In your view:
<script type="text/javascript">
(function() {
window.applifierAsyncInit = function() {
Applifier.init({applicationId: YOUR_APPLICATION_ID, thirdPartyId: "<%= third_party_id %>"});
};
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
a.src = (('https:' == document.location.protocol) ? 'https://secure' : 'http://cdn') + '.applifier.com/applifier.min.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(a, s);
})();
</script>