0
我使用本教程https://developers.facebook.com/docs/opengraph/tutorial/來製作我的第一個應用程序,但是我想使用php變量作爲我的og:標題,就像這個「/>這個php變量每次頁面加載時都會不斷變化,但是當我發佈時我在Facebook的行動似乎與舊題 下面的代碼:。更新時間:標題
<?php
$title = ' Hello world';
// <---- This php variable is changing every time
the page loads but the title is not being recognised
?>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# fitnessgod: http://ogp.me/ns/fb/fitnessgod#">
<meta property="og:locale" content="en_US" />
<meta property="fb:app_id" content="My app Id" />
<meta property="og:type" content="fitnessgod:news" />
<meta property="og:url" content="https://www.fitness-god.com/share-facebook.php" />
<meta property="og:title" content="<?php echo $title; ?>" />
<meta property="og:description" content="let's do sport" />
<meta property="og:image" content="https://www.fitness-god.com/images/sport dinamic.png" />
<script type="text/javascript">
function postCook()
{
FB.api('/me/fitnessgod:share' +
'?news=https://www.fitness-god.com/share-facebook.php','post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'My App id', cookie:true,
status:true, xfbml:true, oauth:true
});
</script>
<fb:add-to-timeline></fb:add-to-timeline>
<h3>
<font size="30" face="verdana" color="grey">
Stuffed Cookies
</font>
</h3>
<p>
<img title="Sports News"
src="https://www.fitness-god.com/images/sport dinamic.png"
width="550"/><br />
</p>
<form>
<input type="button" value="Share news" onClick="postCook()" />
</form>
<fb:activity actions="fitnessgod:share"></fb:activity>
</body>
</html>
感謝您的快速回復!你可以請測試這個,因爲這是我希望我的網頁工作的方式: – 2012-02-12 13:04:28
感謝您的快速回復!你可以測試這個鏈接的請,因爲這是我想用我的api的方式:爲了測試嘗試分享這個,看看是否標題正在改變: test1:https://www.fitness-god.com/share-facebook .php?id = 20 test2:https://www.fitness-god.com/share-facebook.php?id=21 test3:with id = 22每次我的標題都應該被識別!如果id = 20,則爲 – 2012-02-12 13:06:00
; title = Hello world;如果id = 21; title =你好,如果id = 21; title =你好, – 2012-02-12 13:09:28