我想在facebook iframe应用程序中使用以下代码显示"Post to Your Wall"提要对话框:
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:'249725835046216', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'feed',
message: 'Facebook for Websites is super-cool',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
});
</script>
Run Code Online (Sandbox Code Playgroud)
问题是它出现在这样一个新的弹出窗口中:

如果没有出现在弹出窗口中,而不是像这样出现:

我不希望Feed对话框出现在新的弹出窗口中,因为在大多数现代Web浏览器中都会阻止弹出窗口.我不知道为什么会这样.请帮忙.
我正在研究一个测验脚本.因此,我想分享测验的结果,而不是og元数据.
我知道可以使用旧的FB.ui feed动作添加自定义名称,标题,描述和消息,而不是共享URL.例如:
FB.ui({
method: 'feed',
href: url,
name: name,
caption: title,
description: des,
message: message,
picture: img,
}, function(response){});
Run Code Online (Sandbox Code Playgroud)
但是我想这会很快被弃用?!
这也可能与新的份额api一起使用吗?或者我可以用自定义故事来做这件事吗?怎么样?我正在寻找类似的东西
FB.ui({
method: 'share',
href: url,
name: name,
caption: title,
description: des,
message: message,
picture: img,
}, function(response){});
Run Code Online (Sandbox Code Playgroud)
但这不起作用:/它只需要href.其他一切都被忽略,而不是预先填写:(
有没有最好的做法或Facebook推荐的方法来做到这一点?
API文档:https://developers.facebook.com/docs/sharing/reference/share-dialog
谢谢.我非常感谢你的帮助
facebook facebook-sharer facebook-graph-api facebook-javascript-sdk facebook-apps
应用程序中的内容正在使用XHR进行更新.这涉及更改评论框的URL:
<div class="fb-comments" data-href="http://example.com?id=[dynamic]" data-num-posts="2" data-width="470"></div>
Run Code Online (Sandbox Code Playgroud)
在页面完全加载后创建新的Facebook小部件占位符时,如何请求Facebook JS SDK在页面上呈现新元素?
我尝试使用facebook api将数据提取到表单输入中.现在,一切都很顺利,直到我试图获取当前用户的位置.
如果当前用户已经分享了他的位置(他居住的地方),那么我没有遇到任何问题.但是,如果用户没有在Facebook上分享他的位置,我收到一个错误:
Uncaught TypeError: Cannot read property 'name' of undefined
这是我一直在使用的代码.如果你有任何想法如何解决它,请在这里评论:)
<div id="fb-root"></div>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : '*******', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
FB.api('/me', function(response) {
document.getElementById("user_login").value="FB - " + response.username;
document.getElementById("user_email").value=response.email;
document.getElementById("first_name").value=response.first_name;
document.getElementById("last_name").value=response.last_name;
document.getElementById("user_url").value=response.link;
document.getElementById("fbid").value=response.id;
if(response.location …Run Code Online (Sandbox Code Playgroud) javascript facebook facebook-graph-api facebook-javascript-sdk
这已经工作了一个多星期了.
FB.ui({
method: 'send',
to: connectionid,
name: subject,
picture: staticurl + 'images/logoformysite.png',
link: homeurl + '/' + username + '/something=' + var1 +'&somethingelse=' + encodeURI(var2) + '&evenmore=' + encodeURI(var3),
description: invitemessage,
});
Run Code Online (Sandbox Code Playgroud)
我上周最初有一个错误,如果URL在Facebook域内,Facebook会阻止它.我修复了这一点,现在图片和链接都不属于Facebook域,来自我的网站.但这种情况今天开始发生,没有任何改变.这是间歇性的.
An error occurred. Please try again later.
API Error Code: 100 API Error Description: Invalid parameter Error Message: 'link' is invalid.
Run Code Online (Sandbox Code Playgroud)
目前尚不清楚为什么它有时会工作而不是其他时间,即使我将它发送给同一个用户.想知道我是否错过了公告.但我希望它至少会一直失败但事实并非如此.
更新: 我不确定如何在页面上全局设置我在对话框中设置的链接.它会将邮件的收件人发送错误的链接.看一下上面如何在新的开放图形世界中起作用的例子真的很有帮助.
答案2013年8月12日
问题围绕着我们的url是动态的,每次都需要强制缓存.我现在对" https://developers.facebook.com/tools/debug/og/object "进行ajax调用以刷新它,然后启动发送对话框.
我在谷歌找不到任何可以使新推出的facebook帖子嵌入响应的解决方案.有没有人得到解决方案或技巧?谢谢
<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-post" data-href="https://www.facebook.com/notes/facebook-security/national-cyber-security-awareness-month/10151630123500766" ><div class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/notes/facebook-security/national-cyber-security-awareness-month/10151630123500766">Post</a> by <a href="https://www.facebook.com/security">Facebook Security</a>.</div></div>
Run Code Online (Sandbox Code Playgroud) 这个问题长期以来一直困扰着我,我似乎无法找到解决方案,我的Facebook Developer面板中的所有设置都已正确配置,站点URL,应用域和OAuth URL.
当我在iPhone上运行我的应用程序(我通过iTunes安装它)并单击身份验证按钮时,我已成功提示此屏幕:
但是,登录后,我面临一个空白的白色屏幕,而不是被重定向到我的main.html页面.
我正在使用OpenFB插件以及Parse和Facebook Graph API来验证和存储我的用户数据,这是我的登录代码:
的login.html:
$('.facebookLogin').click(function(){
Parse.User.logOut(); // log current user out before logging in
login();
});
function login() {
openFB.login(function(response) {
if(response.status === 'connected') {
console.log('Facebook login succeeded');
Parse.FacebookUtils.logIn("email", { // permission request to use email
success: function(user) {
if (!user.existed()) {
FB.api('/me', function(response) {
var firstName = response.first_name;
var lastName = response.last_name;
var email = response.email;
var user_id = response.id;
user.set("firstName",firstName);
user.set("lastName",lastName);
user.set("email",email);
user.save();
});
window.location.href= "main.html";
}
else { …Run Code Online (Sandbox Code Playgroud) 当我点击注销时...我在控制台中得到了这个异常:
FB.logout()在没有访问令牌的情况下调用.
问题:我已经在Session中保存了Access令牌,我也可以在客户端访问它.我已经检查了这个答案,并且无法理解我如何调用handleSessionResponse方法以及当我点击注销按钮时响应值是多少?/sf/answers/590146931/
我在布局页面(母版页)中有以下代码.
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{!! env("FACEBOOK_APP_ID") !!}',
xfbml : true,
version : '{!! env("Facebook_Version") !!}'
});
FB.AppEvents.logPageView();
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
Run Code Online (Sandbox Code Playgroud)
以下是刀片中的代码(内容页面)
<ul class="nav nav-sidebar">
<li class="active"><a href="#" onclick="logout();">Logout</a></li>
</ul>
<script>
function checkLoginState() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
} else {
} …Run Code Online (Sandbox Code Playgroud) facebook-javascript-sdk facebook-php-sdk laravel-5.3 laravel-5.4
我知道在SO上有大约一百个问题,但是它们可能都不是与Facebook平台上目前正在发生的事情有关的最新信息。似乎关闭SSL的开关已禁用:
可能很难看到,但是“强制HTTPS”切换为灰色,无法切换。我全力支持在生产环境中实施HTTPS,但是为此目的而针对Facebook API构建的所有人是否真的为此在本地服务器上设置了SSL证书?
调用FB.init(之前</body>)的简单事情然后FB.getLoginStatus(callback)不会触发回调函数.
经过一些调试后,我认为SDK停留在"加载"(即FB.Auth._loadState == 'loading')阶段并且永远不会"加载",因此所有回调都会排队,直到SDK加载完毕.如果我在调试期间强制触发"已加载"事件 - FB.Event.fire('FB.loginStatus', 'loaded')如果您有兴趣 - 那么可以正确调用回调.
可能相关的额外细节:
这是怎么回事?为什么SDK永远不会被加载?
谢谢
更新:刚刚在Chrome上试过它并且它有效(不知道为什么它之前没有用).仍然无法在IE中工作