English 中文(简体)
Facebook app is redirected to my website instead of the canvas page on Facebook. [duplicate]
原标题:
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
facebook app getting redirected out canvas view

I have developed an Facebook Application. I have posted the index.php over here. When I click on the App icon from my facebook account i am redirected to the www.mywebsite.com/facebook/index.php page. It should redirect me to the canvas URL of my App - apps.facebook.com/example/, but even after I interchange the appBaseUrl and baseUrl addresses in the code it still gets redirected to my website.

I have used official php-sdk 3.0 that can be downloaded from https://github.com/facebook/php-sdk .

What is the problem? Why is the app not going to my canvas page on Facebook? What changes I have to make in the code below to resolve my problem? If Any one can help me on this, please do answer.

$fbconfig[ appid  ] = "XXXXXXXXXXX";
$fbconfig[ secret ] = "XXXXXXXXXXXXXXXXXXXXXXXXXXX";
$fbconfig[ appBaseUrl ] = "https://apps.facebook.com/example/";
$fbconfig[ baseUrl ] = "http://www.mywebsite.com/facebook/";

include_once "facebook.php";    

$facebook = new Facebook(array(
   appId   => $fbconfig[ appid ],
   secret  => $fbconfig[ secret ],
   cookie  => true,
));

$loginUrl = $facebook->getLoginUrl(
array( scope => email,publish_stream,user_birthday,user_location ));     

if (!(isset($_GET[ code ])))
  echo "<script type= text/javascript >top.location.href =  ".$loginUrl." ;</script>";

else
 {

  $user = $facebook->getUser();

  try {
    $user_profile = $facebook->api( /me );
  } catch (FacebookApiException $e) {
     err($e); 
    $user = null;
  }

$userInfo  = $facebook->api("/$user");

function err($d){
    echo  <pre> ;
    print_r($d);
    echo  </pre> ;
}

}

问题回答

Check your facebook developer settings, make the site_url setting as blank and set the url for facebook app integration.

you should check your Canvas URL, which will display content in facebook app page. if you didn t specify this url in app settings, facebook will redirect user to your Site URL.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签