페이스 북 API로 사용자 생일을 얻으려고합니다. 나는 우리가 지금이 사실에 대해 허가를 요청할 필요가 있음을 알고 있습니다. 난 정말이 API로 페이스 북 사용자 생일 축하하기
그냥 추가하려면이 발견 작동하는 방법을 알고하지 않습니다if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(
array('req_perms' => 'email,read_stream')
);
}
<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>
을이 내 전체 코드 (아주 기본)이다 : 나는 당신의 도움을 주셔서 감사합니다 것
<?php
require 'php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => '4539768XXXXX',
'secret' => 'fe86f3b0b34b3eXXXXXXXXXX',
'cookie' => true,
));
$signedRequest = $facebook->getSignedRequest();
$liked = $signedRequest["page"]["liked"];
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(
array('req_perms' => 'email,read_stream')
);
}
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<style>
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
h1 a {
text-decoration: none;
color: #3b5998;
}
h1 a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<?php
if ($liked) {
header("Location:youlike.php");
} else {
echo "you don't like yet";
}
?>
<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>
<?php if ($user): ?>
<a href="<?php echo $logoutUrl; ?>">Logout</a>
<?php else: ?>
<div>
Login:
<a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
</div>
<?php endif ?>
<?php if ($user): ?>
<h3>Vous</h3>
<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
<h3>Personne connectée</h3>
<pre><?php print_r($user_profile); ?></pre>
<?php else: ?>
<strong><em>Vous n'etes pas loggé!</em></strong>
<?php endif ?>
</body>
<script>
</script>
</html>
미리 감사드립니다!
이어야합니다. 사용자의 생일이 아닌 내 나이 만 볼 수 있다고 생각합니다. 그렇지 않으면 보안 상 위험 할 수 있습니다. – think123
실제로 우리는 여전히 다음과 같이 할 수 있습니다. http://developers.facebook.com/docs/reference/api/user/ – Slrg
이런 경우에 저는 틀 렸습니다. – think123