我已经从Facebook创建了获取好友列表。我得到了答案。我已经开发了它的代码PHP代码。最后在echo变量中存储变量。现在我想在html代码中包含php文件。我更改了设置创建的.htaccess文件。现在我想要如何包含php echo变量特定的地方html?
<div class="col-md-6 two">
<span>36</span>
<p>FRIENDS COUNTR</p>
</div>
这是我的HTML代码。我希望在我的php echo文件中包含该代码
<?php
require '/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxx',
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
$result = $facebook->api('/me/friends');
print "<pre>";
//print_r($result);
$json_output=($result['summary']['total_count']);
echo "<h2>".'<br>FRIENDS COUNTER<br/> '. $json_output. "</h2>";
print "</pre>";
} else {
$statusUrl = $facebook->getLoginUrl();
$loginUrl = $facebook->getLoginUrl(array('scope' => 'user_friends'));
}
?>
我在html页面中尝试过,我已经将html页面的顶部看作是
<?php
session_start();
include('facebook.php');
?>
值打印页面顶部。我想显示这个html页面?
<div class="col-md-6 two">
<span>36</span>
<p>FRIENDS COUNTR</p>
</div>
如何在html文件中添加echo值?请帮忙吗?
答案 0 :(得分:0)
<?php
require '/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxx',
));
$app_id = '{app_id}';
$app_secret = '{app_secret}';
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
$result = $facebook->api('/me/friends');
$json_output=($result['summary']['total_count']);
echo '<div class="col-md-6 two"><span>'.$json_output.'</span><p>FRIENDS COUNTR</p></div>';
} else {
$statusUrl = $facebook->getLoginUrl();
$loginUrl = $facebook->getLoginUrl(array('scope' => 'user_friends'));
}
?>
喜欢这个吗?