【问题标题】:titanium app integration with facebook钛应用程序与 Facebook 的集成
【发布时间】:2013-05-07 15:01:15
【问题描述】:

这几天我开始使用钛并熟悉框架。它真的很酷的框架。现在我正在构建一个试图与 facebook 连接的应用程序......我还在 facebook 开发人员上注册了一个应用程序并获得了 id。但由于某种原因它无法连接...... 我收到如下错误:

Message: Uncaught TypeError: Cannot set property 'appid' of undefined

我的代码如下:(http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Facebook-property-loggedIn)

// Don't forget to set your appid and requested permissions, else the login button
// won't be effective.
Titanium.Facebook.appid = "xxxxxxxxxxxxxxx";
Titanium.Facebook.permissions = ['publish_stream', 'read_stream'];
Titanium.Facebook.addEventListener('login', function(e) {
    if (e.success) {
        alert('Logged in');
    }
});
Titanium.Facebook.addEventListener('logout', function(e) {
    alert('Logged out');
});

// add the button.  Note that it doesn't need a click event or anything.
Titanium.UI.currentWindow.add(Titanium.Facebook.createLoginButton({ top: 50, style: 'wide' }));

在我的 tiapp.xml 中,我添加了以下代码:

<property name="ti.facebook.appid">XXXXXXXXXXX</property>
<modules>
        <module platform="android">facebook</module>
 </modules>

我正在使用 android 2.2 模拟器的最后一件事...我知道我应该在钛应用加速器论坛上问这个问题...我没有这样做,但确实得到了任何回应...认为这里的一些极客可能会帮助我.. 谢谢

【问题讨论】:

  • 看看钛食谱
  • 我紧跟着这本书,但无法通过这个..

标签: android-emulator titanium


【解决方案1】:

我正在使用带有 3.1 SDK 的钛工作室。所以我猜 Titanium.Facebook 在较新的版本中已被弃用。http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Facebook.LoginButton)

下面的代码 sn-p 对我有用..

var win = Ti.UI.createWindow({backgroundColor: 'white'});
var fb = require('facebook');
fb.appid = "xxxxxxxxxxxxxxx";
fb.permissions =  ['publish_stream'];

fb.addEventListener('login', function(e) {
    if (e.success) {
        alert('Logged in');
    }
});
fb.addEventListener('logout', function(e) {
    alert('Logged out');
});
win.add(fb.createLoginButton({
    top : 50,
    style : fb.BUTTON_STYLE_WIDE
}));
win.open()

干杯...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多