「Facebookでログイン」ボタンを組み込みたいWebサイトを開発しました。私は必要な部分をコーディングし、そのためのFacebookアプリケーションも作成しました..私のコードでは、アプリIDと秘密鍵も渡しました。そうした後でも、ボタンを押してFacebook経由でログインすると、「パラメーターapp_idが必要です」というエラーが表示されます。これは私のログインスクリプトです
<?php
include 'fbaccess.php'
if(empty($user))
{
?>
<form name="fblogin" action="<?php echo $loginUrl;?>">
<input type="submit" name="fbsubmit" value="Login with Facebook"/>
</form>
<?php
}
else {
echo $user_info;
}
?>
これは私のfbaccess.phpコードです
<?php
$app_id = APP_ID;
$app_secret = APP_SECRET;
$site_url = "www.jajabora.com/index.php";
include_once "src/facebook.php";
//creating the object of facebook from the API
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
));
//getting the user id to check whether the user is logged in or not
$user = $facebook->getUser();
//if user is not authenticated api/me will throw an exception, hence we will know he isnt logged in after logging out
/*checks if the user is logged in or not*/if($user){
// Single query method
try{
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
}/*if exception the user has logged out after logging in hence not authenticated*/
catch(FacebookApiException $e){
error_log($e);
$user = NULL;
}
// Single query method ends
}
if($user){
// Get logout URL
$logoutUrl = $facebook->getLogoutUrl();
}else{
// Get login URL
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'publish_stream, user_birthday,user_location,email,first_name,last_name,gender',
));
}
if($user){
// Proceed knowing you have a logged in user who has a valid session.
//========= Batch requests over the Facebook Graph API using the PHP-SDK ========
// Save your method calls into an array
$queries = array(
array('method' => 'GET', 'relative_url' => '/'.$user)/*,
array('method' => 'GET', 'relative_url' => '/'.$user.'/home?limit=50'),
array('method' => 'GET', 'relative_url' => '/'.$user.'/friends'),
array('method' => 'GET', 'relative_url' => '/'.$user.'/photos?limit=6'),*/
);
// POST your queries to the batch endpoint on the graph.
try{
$batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST');
}catch(Exception $o){
error_log($o);
}
//Return values are indexed in order of the original array, content is in ['body'] as a JSON
//string. Decode for use as a PHP array.
$user_info = json_decode($batchResponse[0]['body'], TRUE);
$feed = json_decode($batchResponse[1]['body'], TRUE);
/*$friends_list = json_decode($batchResponse[2]['body'], TRUE);
$photos = json_decode($batchResponse[3]['body'], TRUE);*/
//========= Batch requests over the Facebook Graph API using the PHP-SDK ends =====
try {
$publishStream = $facebook->api("/$user/feed", 'post', array(
'message' => 'Check out jajabora.com',
'link' => 'http://jajabora.com'/*,
'picture' => 'http://25labs.com/images/25-labs-160-160.jpg'*/,
'name' => 'Jajabora',
'caption' => 'jajabora.com',
'description' => 'A carpooling website. highly recommended to save fuel and cost of travel',
));
}catch(FacebookApiException $e){
error_log($e);
}
}
?>
私を案内してください。私はFacebookログインコーディングの初心者です