我想在呈现iframe登录以请求扩展权限之前检查已登录用户的权限,但是iframe弹出窗口被浏览器阻止(ff,chrome tests).我想避免这种情况,我很确定它因为js函数的结果是'嵌套的' - 我的js聪明才有限,所以请原谅.
我猜测如果我可以保留原始函数中的所有内容而不传递结果,浏览器仍然会将登录iframe视为"用户启动"而不是阻止.
但我无法做到这一点 - 例如,为什么以下结果导致数据=未定义.
var data = FB.api(
{
method: 'fql.query',
query: 'SELECT create_event FROM permissions WHERE uid=' + response.session.uid
});
alert(data); // = undefined
Run Code Online (Sandbox Code Playgroud)
我当前的完整代码是:
<button id="myButton" >Test Publish Event</button>
<script>
$('#myButton').bind('click', function() {
FB.getLoginStatus(function(response) {
if (response.session) {
// logged in and connected user, someone you know
FB.api(
{
method: 'fql.query',
query: 'SELECT create_event FROM permissions WHERE uid=' + response.session.uid
},
function(response) {
if(response[0].create_event == 1) {
alert('permission granted');
} else {
alert('permission absent'); …Run Code Online (Sandbox Code Playgroud) 所以当用户点击"喜欢"按钮时,我正在尝试进行一些事件处理.
我的Facebook按钮是通过以下方式异步创建的:
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
Run Code Online (Sandbox Code Playgroud)
这很有效.
我也运行以下功能:
window.fbAsyncInit = function() {
FB.init({status: true, cookie: true, xfbml: true});
FB.Event.subscribe("xfbml.render", function() {
console.log('xfbml.render');
FB.Event.subscribe("edge.create", function(targetUrl) {
console.log('edge.create');
});
FB.Event.subscribe("edge.remove", function(targetUrl) {
console.log('edge.remove');
});
});
};
Run Code Online (Sandbox Code Playgroud)
到目前为止,当我加载页面时,我在控制台中得到'xfbml.render'.然后我点击"赞"按钮,我什么都没得到.
我想把它吐出控制台消息'edge.create'.
有谁知道是什么原因引起的?
我之前将这个页面放在一个可公开访问的网站上(它目前在我的开发平台上)并且它仍然无效.如果要求,我可以再次.
我为网站创建了一个应用程序,并为其提供了一个网站URL.(网站网址实际上并不是真实的.它会在我的本地主机名文件中被覆盖以用于开发目的.这有关系吗?).
我使用示例代码创建请求对话框,以将请求发送到另一个Facebook帐户.我使用了多用户界面,没有to:字段.当我在我的其他Facebook帐户刷新页面时,我看到世界图标上的红色1只是一瞬间,但随后它消失了,没有找到任何通知.每次发送请求时都会这样做.我的请求是否有问题,他们会立即被删除?我是否以某种方式错误地配置了我的应用?
我正在使用phonegap facebook插件和facebook javascript api.这是我的代码
FB.init({
appId: "xxxxxxxxxxxxxxx",
status: true,
oauth :true,
nativeInterface: CDV.FB,
//channelURL : 'www', // Channel File
cookie: true,
//useCachedDialogs: false,
xfbml: true
});
FB.login(function(response) {
if (response.authResponse) {
alert(response.authResponse.userID); // literally shows three dots
FB.api('/me', function(me){
if (me.id) {
alert(me.id); // this works
}
});
}
}, { scope: "email" });
Run Code Online (Sandbox Code Playgroud)
我可以从authResponse获取accessToken ....它是一个长字符串.但是userID字段实际上是"......".我可以通过对服务器进行额外的往返来获取用户的ID,并使用另一个图形API调用来获取,/me但这似乎很浪费.
javascript facebook facebook-javascript-sdk phonegap-plugins cordova
大多数网络应用程序使用Facebook的PHP SDK或Javascript SDK来处理登录吗?
我不清楚他们的文档为什么我会使用更复杂的PHP SDK?它是否让我更自由地定制登录体验等?
我在使用Phonegap 3.0.0和他们的Facebook插件时遇到了这个问题.我按照他们对信的解释(两次),我开始认为要么我做了一些非常错误的事情,要么我的版本没有正确排列.
我从hackbook和simple.html得到的错误是:
ERROR: Plugin 'org.apache.cordova.facebook.Connect' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
Run Code Online (Sandbox Code Playgroud)
因此,根据我在网上找到的所有内容(在这种情况下并不是很多看到他们在最近的版本中进行了一些市长更改),它似乎与我的plist或xml有关.
所以我希望有人已经让它运行,或者知道我做错了什么.
至于config.xml,我正在使用www文件夹中的那个(是正确的吗?),并添加:
<gap:plugin name="com.phonegap.plugins.facebookconnect">
<param name="APP_ID" value="[app_id]" />
<param name="APP_NAME" value="[app_name]" />
</gap:plugin>
Run Code Online (Sandbox Code Playgroud)
至于plist我最后添加:
<key>FacebookDisplayName</key>
<string>[app_name]</string>
<key>FacebookAppID</key>
<string>[app_id]</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>[app_name]</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb[app_id]</string>
</array>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
其余的工作按照github页面教程中的说明完成.
我有一个Facebook登录实施的网站.我的应用程序拥有用户电子邮件的权限.即使用户使用Facebook登录我的应用程序,我也只能检索他/她的名字或基本信息.不是电子邮件.所以,这是我从Facebook开发者网站上复制的代码:
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxxx', // App ID
channelUrl : '//domain.org/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
FB.login();
} else {
FB.login();
}
});
};
// Load the SDK asynchronously
(function(d){
var js, id = …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的应用程序获取Facebook用户电子邮件.但是当我查询时,电子邮件地址将返回为undefined.我没有得到如何处理它.
这是我的代码 -
<body>
<script>
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
FB.login(function(response) {}, {
scope: 'email'
});
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
FB.login(function(response) {}, {
scope: 'email'
});
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId: 'app id',
cookie: true, // …Run Code Online (Sandbox Code Playgroud) javascript facebook facebook-javascript-sdk facebook-graph-api-v2.0
我正在开发一个包含iOS和Android本机应用程序的webapp.只需在两个平台的webView中显示webapp即可完成此操作.我遇到了Facebook登录和Android平台的问题.
登录到Facebook可以通过我的"黑客"工作但是当应用程序在之后检查登录状态时它总是返回未知(这表明SDK不知道用户是否登录到Facebook).
webView:
WebView mainWebView = (WebView) findViewById(R.id.petpulseWebView);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.clearCache(true);
Run Code Online (Sandbox Code Playgroud)
Javascript代码:
// This function works, user is redirected to the Facebook login like he/she should
$(document).on('click', '#loginfb', function (e) {
e.preventDefault();
$.mobile.loading('show');
// Worst hack.ever
window.location.href = 'https://m.facebook.com/v2.2/dialog/oauth?client_id=xxxxx&response_type=code&redirect_uri=' + encodeURIComponent($('#base_url').val() + 'index.php?id=4') + '&scope=email×tamp=';
});
// Checking if both the Facebook SDK and the correct page is loaded, if the user has code in GET he/she has been redirected from a Facebook login
function check_all_loaded () …Run Code Online (Sandbox Code Playgroud) 我的网站允许用户通过Fb按钮登录,我正在使用FB/Parse.com JDK进行此https://parse.com/docs/js/guide#users-facebook-users
一旦识别出用户,下面的代码就会记录用户并将其转发到网址上.这在Chrome下可以正常使用,但无法使用Safari,该页面只保留在空白的fb.html页面上
我已经看到有一些历史问题
window.location.href =
但是,找不到适用于我的解决方案的修复程序.有没有人知道这方面的方法?
Parse.FacebookUtils.logIn(null, {
success: function(user) {
if (!user.existed()) {
} else {
window.location.href="user_home.html";
}
},
error: function(user, error) {
}
});
Run Code Online (Sandbox Code Playgroud)