正如您在下面看到的,我试图在我的文档加载后调用这两个函数,但是当我运行代码时,我收到以下错误:syntax error unexpected token: <
编辑:我在下面添加了我的 html 代码,以便您仔细查看。谢谢
这是我的 index.php 文件:
<?php
require 'fb-php-sdk/facebook.php';
$app_id = '251156051648844';
$app_secret = 'be37135d238e66ddce8f4ce8db20e668';
$app_namespace = '';
$app_url = 'http://www.paulmeskers.com/rutgers/twenty/canvas/';
$scope = 'email,publish_actions';
// Init the Facebook SDK
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
));
// Get the current user
$user = $facebook->getUser();
// If the user has not installed the app, redirect them to the Auth Dialog
if (!$user) {
$loginUrl = $facebook->getLoginUrl(array(
'scope' => $scope,
'redirect_uri' => $app_url,
));
print('<script> top.location.href=\'' . $loginUrl . '\'</script>');
}
if(isset($_REQUEST['request_ids'])) {
$requestIDs = explode(',' , $_REQUEST['request_ids']);
foreach($requestIDs as $requestID) {
try {
$delete_success = $facebook->api('/' . $requestID, 'DELETE');
} catch(FacebookAPIException $e) {
error_log($e);
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Twenty Questions</title>
<meta property="og:title" content="ttt" />
<meta property="og:type" content="activity" />
<meta property="og:url" content="https://apps.facebook.com/251156051648844/" />
</head>
<body id="yo">
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script type='text/javascript' src='jquery-1.7.2.min.js'></script>
<script type='text/javascript' src='ui.js'></script>
<script>
var appId = '<?php echo $facebook->getAppID() ?>';
var uid;
// Initialize the JS SDK
FB.init({
appId: appId,
cookie: true,
});
FB.getLoginStatus(function(response){
uid = response.authResponse.userID ? response.authResponse.userID: null;
});
function authUser() {
FB.login(function(response) {
uid = response.authResponse.userID ? response.authResponse.userID : null;
}, {scope:'email,publish_actions'});
}
</script>
<input type="button" id="b1" value="Create Game" onClick="createGame(uid)"/>
<input type="button" id="b2" value="Share this game" onClick="shareOnTimeline()" />
<input type="button" id="b4" value="fetch created games" onClick="fetch_creator_games(uid)" />
<input type="button" id="b5" value="fetch joined games" onClick="fetch_joined_games()"/>
<input type="button" id="b3" value="tewst" onClick="build_creator_ui()" />
<p><b>Games created by me:</b></p>
<div id="createdGames" ></div>
<p>------------------------------------------------------</p>
<p><b>Games created by others:</b></p>
<div id="invitedGames" ></div>
</body>
</html>