次のコードは chrome と IE で完全に動作しますが、Firefox でテストすると、「エラーが発生しました。後でもう一度試してください」というエラーが返されます。コードの問題点を教えてください。以下は Facebook API に関連するコードです。
$user_id = $facebook->getUser();
if ($user_id) {
try {
// Fetch the viewer's basic information
$basic = $facebook->api('/me');
} catch (FacebookApiException $e) {
// If the call fails we check if we still have a user. The user will be
// cleared if the error is because of an invalid accesstoken
if (!$facebook->getUser()) {
header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
exit();
}
}
if (check_user($user_id,$promo) && check_friend($user_id)>0){
header('Location: Thankyou.php');
}
if (!check_promo()){
header('Location: Thankyou.php');
}
// Fetch the basic info of the app that they are using
$app_info = $facebook->api('/'. AppInfo::appID());
$app_name = idx($app_info, 'name', '');
?>
<!DOCTYPE html>
<html xmlns:fb="http://ogp.me/ns/fb#" lang="en">
<head>
<script type="text/javascript">
function logResponse(response) {
if (console && console.log) {
console.log('The response was', response);
}
}
//Perhaps the problem come from here
$(function(){
// Set up so we handle click on the buttons
$('#postToWall').click(function() {
FB.ui(
{
method : 'feed',
link : $(this).attr('data-url')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
$('#sendRequest').click(function() {
FB.ui(
{
method : 'apprequests',
message : $(this).attr('data-message')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
var request_ids = [];
var friend_ids = [];
for(i=0; i<response.to.length; i++) {
//var temp = response.to[i] + '_' + response.to[i].name;
request_ids.push(response.request);
friend_ids.push(response.to[i]);
}
var requests = request_ids.join(',');
var friends = friend_ids.join(',');
$.post('friend_handler.php',{uid: <?php echo $user_id; ?>, fid: friends, rid: requests},function(resp) {
});
}
}
);
});
});
</script>
<?php $caption = "Hello";
$description = "Byebye";
?>
<script>
FB.init({appId: "<?php echo AppInfo::appID(); ?>", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'http://apps.facebook.com/mas-amazing-journey/',
picture: 'http://www.xman.com/content/mas-admin/my/en/site-configuration/homepagethreatre/book/AmazingWorldwideDeals/_jcr_content/contentpar/masimage_9126.img.jpg/1339349457238.jpg',
name: 'Amazing Journey',
caption: '<?php echo $caption; ?>',
description: '<?php echo $description; ?>'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
<!--[if IE]>
<script type="text/javascript">
var tags = ['header', 'section'];
while(tags.length)
document.createElement(tags.pop());
</script>
<![endif]-->
<script src="//connect.facebook.net/en_US/all.js"></script>
</head>
<body>
<header class="clearfix">
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo AppInfo::appID(); ?>', // App ID
channelUrl : '//<?php echo $_SERVER["HTTP_HOST"]; ?>/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Listen to the auth.login which will be called when the user logs in
// using the Login button
FB.Event.subscribe('auth.login', function(response) {
// We want to reload the page now so PHP can read the cookie that the
// Javascript SDK sat. But we don't want to use
// window.location.reload() because if this is in a canvas there was a
// post made to this page and a reload will trigger a message to the
// user asking if they want to send data again.
window.location = window.location;
});
FB.Canvas.setAutoGrow();
};
// Load the SDK Asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<?php if (isset($basic)) { ?>
<p id="picture" style="background-image: url(https://graph.facebook.com/<?php echo he($user_id); ?>/picture?type=normal)"></p>
<h1>Welcome, <strong><?php echo he(idx($basic, 'name')); ?></strong></h1>
<p class="tagline">
Good Luck!
</br>
</p>
<div id="share-app">
<!-- <p>Tools for your to invite your friends and spread your words:</p>-->
<ul>
<li>
<a href="#" class="facebook-button" onclick='postToFeed(); return false;' >
<span class="plus">Share this on my wall</span>
</a>
</li>
<!-- <li>
<a href="#" class="facebook-button speech-bubble" id="sendToFriends" data-url="<?php echo AppInfo::getUrl(); ?>">
<span class="speech-bubble">Share Your Amazing Journey</span>
</a>
</li>-->
<li>
<a href="//<?php echo $_SERVER["HTTP_HOST"]; ?>/Thankyou.php" class="facebook-button speech-bubble" id="thankyou">
<span class="speech-bubble">SUBMIT</span>
</a>
</li>
</ul>
<li>
<a href="#" class="facebook-button apprequests" id="sendRequest"
data-message="I have just invited you to fly with me">
<span class="apprequests"><img border="0" class="facebook-button apprequests" id="sendRequest" src="http://i.imgur.com/lRdP3.jpg" style="width: 680px;margin-top:10px;z-index: -9999;"/></span>
</a>
</li>
</div>
<div id="guides"></div>
<?php } else { ?>
<section id="get-started">
<p>Oops, You're out of track... Please reload the page to start over!</p>
</section>
<?php } ?>
</header>
</body>
</html>
エラーのある Firefox から返される URL
エラーのある Chrome から返される URL