Reputation: 31
I've made an application, this application is in a fanpage tab. But when someone invite his friends, the invitation redirect to the application page, not the fanpage tab.
I use that :
function invite(){
FB.ui({
method: 'apprequests',
message: 'message',
data: 'tracking information for the user'
},
function(response) {
location.href="CANVAS_URL?req="+response.request_ids;
}
);
In my app configuration i have :
URL canvas : url on my website
Tab url : url on my website
How can i do?
Upvotes: 3
Views: 4086
Reputation: 379
If you are using PHP, you can use $_SESSION variables.
<?php
session_start();
$app_token = '?'.file_get_contents('https://graph.facebook.com/oauth/access_token?client_id='.FACEBOOK_APP_ID.'&client_secret='.FACEBOOK_SECRET.'&grant_type=client_credentials');
if ( isset($_GET['request_ids']) && !empty($_GET['request_ids']) ) {
$_SESSION['request_ids'] = $_GET['request_ids'];
header('Location: ' . FACEBOOK_PAGE_TAB );
}
if ( isset($_SESSION['request_ids']) && !empty($_SESSION['request_ids']) ) {
if ( strpos($_SESSION['request_ids'], ',') !== false ) {
$request_ids = explode(',', $_SESSION['request_ids']);
$_SESSION['request_ids'] = $request_ids[0];
var_dump($_SESSION['request_ids']);
}
$request = json_decode(file_get_contents('https://graph.facebook.com/'.$_SESSION['request_ids'].$app_token));
var_dump($request);
}
?>
$_SESSIONs seem to be the best solution when you're making a user jump between apps.facebook.com/yourapp/ and facebook.com/yourpage/?sk=app_123456 and vice versa.
Cheers,
Upvotes: 3
Reputation: 5974
I had a similar problem. This is what I did:
in the PHP page that you defined as the canvas url...
if(isset($_GET["request_ids"]))
{
$page_id = 123;
$app_id = 321;
$url = "http://www.facebook.com/pages/FAN_PAGE/$page_id?sk=app_$app_id";
?>
<script type="text/javascript">
top.location.href = "<?=$url?>";
</script>
<?
exit;
}
the idea is that you can determine when a user is seeing you app home page following a recomendation
Upvotes: 2
Reputation: 11
Go to your fanpage's app tab, copy that url and paste in the 'Bookmark Url' field in your app's settings.
People responding to apprequests will then be directed to your fanpage tab.
Upvotes: 1