Reputation: 1554
I am creating a Facebook Tab Application. People create their profile and each profile has a like button. The person who gets the most likes wins.
The problem we are facing now is how to give the URL to a user, so that the user can share the url (so that they can get more likes). Suppose I give the url fb.com/appname/id=12
? Should I be able to get the details of user with id 12
in my Facebook Tab Application?
with the graph API?
Upvotes: 0
Views: 458
Reputation: 130
As a solution for this you can use app_data parameter. You can pass additional parameters to a FB tab using app_data parameter in your url like this https://www.facebook.com/pages/FB-App-Test13191195702111?sk=app_234567890&app_data=MY_CUSTOM_DATA
<?php
$data = array();
$signed_request = '';
$app_data = '';
if(isset($_REQUEST['signed_request'])) {
$signed_request = $_REQUEST['signed_request'];
$secret = YOUR_APP_SECRET
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if(isset($data['app_data'])) {
$app_data = $data['app_data'];
}
}
Use above php code to read your custom data in url to $app_data
$app_data will be equals to "MY_CUSTOM_DATA".
Upvotes: 3