udj*_*lip 2 javascript php facebook fbml fbjs
我目前有以下方法创建一个"共享网址",基本上是在应用程序中插入onclick =""的代码.
问题是,现在我们已经不再拥有Facebook FBML应用程序,只有iframe - 我现在需要包含一个库才能使其工作吗?或者我应该更改代码,我已经使用Google搜索,但答案是广泛的不确定或后退,以迫使它工作.
public function getShareUrl($title, $url, $caption, $description, $imageSrc, $shareButtonText = 'Share your thoughts!')
{
$url .= "var attachment = {
'name':'$title',
'href':'$url',
'caption':'$caption',
'description':'".$description."',
'media':[{
'type':'image',
'src':'$imageSrc',
'href':'$url'
}]
};
var actionLinks = [{
'text':'Join the app now',
'href':'$url'
}];
Facebook.streamPublish('', attachment, actionLinks, null, '$shareButtonText');
return false;";
return $url;
}
Run Code Online (Sandbox Code Playgroud)
谢谢大家!:)
小智 11
要在Facebook应用程序中显示共享弹出窗口,您必须使用Javascript SDK
你可以这样做:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title></title>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
appId : 'yourappid',
status : true,
cookie : true,
xfbml : true
});
</script>
<script type="text/javascript">
function streamPublish(name, description, hrefTitle, hrefLink, userPrompt, imageSrc, imageUrl) {
FB.ui({
method: 'stream.publish',
message: '',
attachment: {
media: [{
type: 'image',
src: imageSrc,
href: imageUrl
}],
name: name,
caption: '',
description: (description),
href: hrefLink
},
action_links: [{
text: hrefTitle,
href: hrefLink
}],
user_prompt_message: userPrompt
}, function (response) {
// do something when you have posted
});
}
function publishStream() {
streamPublish("Stream Publish", 'sample publish', 'do something cool', 'http://example.com', "My fb app", 'http://bit.ly/AJTnf', 'http://bit.ly/hifZk');
}
</script>
<p>Stream Publish Test</p>
<a href="#" onclick="publishStream(); return false;">Post a story</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7503 次 |
| 最近记录: |