在 sencha touch 2 中使用 oAuth 连接 facebook [英] using oAuth in sencha touch 2 to connect facebook

查看:23
本文介绍了在 sencha touch 2 中使用 oAuth 连接 facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sencha touch 2 没有提供连接facebook的功能/库吗.

Aren't there any functions/libraries provided by sencha touch 2 to connect with facebook.

到目前为止我的线索较少

I am clue less so far now

我们可以在 sencha touch 中使用 facebook javascript sdk 吗?

Can we use facebook javascript sdk inside sencha touch ?

我发现以下教程很好,我们可以将其与 extjs mvc 合并

I have found following tutorial good , can we merge it with extjs mvc

http://thinkdiff.net/facebook/new-javascript-sdk-oauth-2-0-based-fbconnect-tutorial/

推荐答案

我猜这取决于您想如何连接.对我来说,我只需要连接并显示 Facebook 页面的墙贴,即可在我的 iPad 上显示.我这样做的方式如下:登录到 facebook 开发人员并创建一个应用程序.给它一个名字,例如Senchatouch 应用程序.它将生成一个 appID 和密钥.

Depends how you want to connect I guess. For me, I just needed to connect and display the wall posts of a facebook page to display on my iPad. The way I have done it is as follows: Login to facebook developers and create an app. Give it a name e.g. Senchatouch App. It will generate an appID and secret key.

然后您需要通过查询此链接找到您的 facebook 用户名:

You then need to find your facebook username id by querying this link:

https://graph.facebook.com/[用户名]

https://graph.facebook.com/[username]

完成后,您必须转到 Facebook Graph API 资源管理器并输入该 ID,然后您才能看到示例响应.

Once you have that then you have to go to the Facebook Graph API explorer and type that ID in and you can see an example response.

然后您需要将访问令牌附加到此链接:

Then you need to append the access token to this link:

https://graph.facebook.com/51539791474/feed?access_token=ACCESS_TOKEN

所以你有类似的东西:

https://graph.facebook.com/51539791474/feed?access_token=AAAFnhgQ0ZAHIBAAbiopuvZAa8zlEmRyxKtZBTcgspJIJ21tVwI17xZCJEbgtNRaMUCnGBVwUa1zE7s6ZBRzg6rJ5UGIEBhZAQfMsCrrT0GVQZDZD

这是您可以在 sencha touch 2 中的普通 JSONP 代理中使用的链接.

This is the link you can use in a normal JSONP proxy in sencha touch 2.

我的商店代码:

Ext.define('TCApp.store.Facebook', {
extend: 'Ext.data.Store',
requires: [
    'TCApp.model.Facebook'
],

config: {
    autoLoad: true,
    model: 'TCApp.model.Facebook',
    storeId: 'Facebook',
    proxy: {
        type: 'jsonp',
        url: 'https://graph.facebook.com/51539791474/feed?access_token=AAACEdEose0cBAAJt7hcZCdkHHK8hOjZBDFd8GSfg2xkI6hj5AghswWn7MvBTz4B4xooN4t2fXvMmTZCrxAq4t5ofnnPIY7oZBebnbuB5wQZDZD',
        reader: {
            type: 'json',
            rootProperty: 'data'
        }
    }
}
});

和我的模型:

Ext.define('TCApp.model.Facebook', {
extend: 'Ext.data.Model',
config: {
    fields: [
        {
            name: 'message'
        },
        {
            name: 'picture'
        },
        {
            name: 'link'
        },
        {
            name: 'description'
        }
    ]
}
});

然后我使用这个 itemTpl 将它绑定到一个简单的列表:

I then bind this to a simple list using this itemTpl:

'<div class="wholeitem"><img src="{picture}" class="facebookthumb" />{message}</div>',
    '<div class="smalltext">{description}</div></div>',

我遇到的唯一问题是到期,似乎每个访问令牌都有 2 小时的到期时间.我还没有弄清楚如何扩展它,如果你发现请发布解决方案或链接到它.谢谢

The only problem I am having is the expiry, it seems each access token has an expiry of 2 hours. I haven't worked out how to extend it yet, if you find out please post the solution or link to it. Thanks

:-)

这篇关于在 sencha touch 2 中使用 oAuth 连接 facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆