- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在使用 Graph API 的 FB javascript 驱动程序来允许用户从他们的 Facebook 帐户中选择照片。他们第一次连接时,系统会提示他们登录:
FB.login(function(res) {
if (res.status == 'connected') {
auth = res.authResponse; // cache auth response
getAlbums();
}
});
如果成功,我缓存返回的 auth 对象并立即获取用户的相册:
function getAlbums() {
FB.api('/me/albums', function(res) {
albums = res.data;
});
}
使用返回的对象,我遍历相册并显示它们的 cover_photo
:
https://graph.facebook.com/{{album.cover_photo}}/picture?type=normal&access_token={{auth.accessToken}}
用户第一次登录时,所有封面照片都是问号图标。但是,如果用户刷新或返回页面,应用程序会重新进行身份验证,识别用户已经登录,并显示正确的 cover_photo 缩略图。
如何让新认证的用户能够看到他们的封面照片?
最佳答案
我不确定,但我想您还没有订阅authResponseChange event .
下面的一段简单代码与您正在寻找的相同-
<html>
<head></head>
<body>
<div id="fb-root"></div>
<script>
var access_token = "";
window.fbAsyncInit = function()
{
FB.init({
appId : '<APP-ID>',
status : true,
cookie : true,
xfbml : true
});
FB.Event.subscribe('auth.authResponseChange', function(response)
{
access_token = response.authResponse.accessToken;
if (response.status === 'connected')
{
FetchUserPhotos();
}
else if (response.status === 'not_authorized')
{
FB.login('scope: user_photos');
}
else
{
FB.login('scope: user_photos');
}
});
};
// Load the SDK asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function FetchUserPhotos()
{
FB.api('/me/albums', function(response)
{
var albums = response.data;
for(var i=0; i<albums.length; i++)
{
var album = albums[i];
if(album.cover_photo != undefined)
{
FB.api("/"+album.cover_photo+"?access_token="+access_token, function(cover_photo)
{
console.log(cover_photo.source);
});
//console.log("https://graph.facebook.com/"+album.cover_photo+"/picture?type=normal&access_token="+access_token);
}
}
});
}
</script>
<fb:login-button scope="user_photos" show-faces="true" width="200" max-rows="1"></fb:login-button>
</body>
</html>
希望对您有所帮助,祝您好运!
关于javascript - 为什么 Graph API 在第一次登录时返回我相册的问号封面照片,而在后续登录时返回正确的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20139858/
我正在制作游戏并有一系列“房间”图像,这些图像使用 background-size: cover 进行缩放(并在必要时进行裁剪)以适应浏览器窗口。 . 我想将一些游戏内元素放置在这些图像的关键位置之上
我正在尝试构建一个像个人资料/封面布局这样的 facebook,但我正在为正确的布局而苦苦挣扎。 我目前拥有的: http://jsfiddle.net/kvEBF/
我正在尝试全屏拉伸(stretch)图像(封面):http://www.bootply.com/114850 我有一个简单的菜单和一个号召性用语按钮,但图像仅覆盖菜单并停在那里。 部分样式如下。 .s
我正在生成 epub 图书文件,但遇到了一个问题。它不读我的封面。这是 cover.xhtml 我做错了什么吗?关于 epub 创建的 IMB 文档告诉我,我唯一需要的是 cover.html 文件和
我使用了许多覆盖的背景图像。 如果我在页面内容区域和固定的左侧面板内使用相同的图像,它会非常频繁地闪烁。 转载: http://jsfiddle.net/7aUnL/8/ HTML:
我想获取文件的increment id,代码如下: // get increment id func GetID() uint64 { appIdLock.Lock() defer a
您好,我正在尝试让封面照片填满整个页面,但没有修复。我希望这样,一旦您开始滚动封面照片滚动和内容显示。我已将高度参数设置为 900 ish 以适合大多数屏幕,但我正在寻找一种方法让它覆盖所有浏览器/分
每当背景图像发生变化时,我都需要它来覆盖主体。我正在使用 background-size: cover,但它似乎不起作用。 body { position: relative; margi
我正在尝试使用以下方法获取 FB 页面的封面 url: $fql_query_url = "https://graph.facebook.com" ."/$fb_id[id]?fields=c
关于 ipad 和 iphone 的大小以及如何使用不同的 css,我遇到了几种方法和问题。真的有必要吗,尤其是现在 ipad 和 iphone 的版本越来越多,每个设备都有不同的背景? 几乎每个关于
.slide{ background: 50% 50% / cover; } background: 50% 50%/cover 有什么作用? 我知道后台语法是这样的 http://www.w
我正在尝试将多个 div 放置在背景图像之上,以产生很酷的效果。主要问题是网站是响应式的,图像也是如此 - 它是 background-size: cover 这使得在查看更大/更小的屏幕时很难将叠加
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
您好,对于网上商店,我希望产品 block 像书本一样打开。并在 de inside-left 上显示图像(打开时) 我试过这样做。它工作正常,但我希望黑色 div 向左打开。这个将包含图像。当我放一
我正在创建一个不垂直滚动的页面。这是供引用的问题页面 - http://horizonwebtest.zxq.net/knowledgebase/ 除以下两点外,它运行良好: 在 iPad(可能是其他
我希望你能帮助我,我被这个问题困住了。 此处示例:http://myko.dk/pegasus/index.html (进行中) 我想让背景图像自动调整大小以适合浏览器宽度。现在,如您所见,图像在调整
如果有人能帮助我并告诉我如何用 CSS/HTML 制作背景封面,我将不胜感激。 我打算做的是制作一个 100% 宽度和 270 像素高度的封面,这将适合并且不会拉伸(stretch)我的图像,我不介意
今天我发现 Firefox 18.0.2 有一个奇怪的行为。即使更新到 FF19.0 也无济于事。 我需要创建具有动态大小并保持特定纵横比的缩略图。可能还有其他更好的解决方案,如下所示。 Html:
我用过Jcrop广泛,但我想以与 Facebook 用于裁剪其封面图像非常相似的方式裁剪图像。 因此,我希望 div 具有某种固定大小,其中背景保存其原始大小的可拖动图像,用户拖动该图像并找到要裁剪的
我正在从图片选择器中挑选一张图片,然后我想更改该图片作为 Facebook 封面的比例。我有一张图片,假设它的分辨率为 640 宽和 480 高,我想将其更改为 facebook 封面(851 像素宽
我是一名优秀的程序员,十分优秀!