我有以下 HTML 表单:
<div id="online_form">
<form id="online_form_facebook" action="user_form.php" name="online_form_facebook">
<div class="field">
<div class="label">
<label for="user_email">Email:</label></div>
<div class="input">
<input id="user_email" name="user_email" readonly="readonly" type="text" value="<?php echo $user_profile['email'] ?>" /></div>
</div>
请问如何使用来自 Facebook 的用户数据填充电子邮件字段(和其他字段)?
这是我必须从 Facebook 获取值的代码:
<?
ob_start();
require_once('library/facebook.php');
$app_id = "247151652061393";
$app_secret = "123456789012345567890";
// Init facebook api.
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => false,
));
//Facebook Authentication part
$user_id = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl(
array(
'scope' => 'publish_stream,user_likes,offline_access,email,user_birthday'
)
);
if (!$user_id) {
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
exit;
}
?>
以上不起作用。请问如何填写这样的字段?