Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

externalAccountLink not working with Facebook 4.0.1 and SDK 3.5.2.v20150313152423

$
0
0

Can someone please check my example code with externalAccountLink? I provided the source code below. If you create the account without Facebook and then authorize Facebook and call externalAccountLink the function returns success but this is not true! There is no Facebook entry in server app management and the search friends function fails complaining that the account is not authorized for Facebook. code

var Cloud = require('ti.cloud');
 
var facebook = require('facebook');
facebook.appid = 1455001824784603;
facebook.permissions = ['read_stream','email','user_friends'];
 
var onFacebookLogin=function(e) {
    facebook.removeEventListener('login', onFacebookLogin);
    Cloud.SocialIntegrations.externalAccountLink({
        type: 'facebook',
        token: facebook.accessToken,
    }, function (e) {
        if (e.success) {
            var user = e.users[0];
            console.log("accountlink successful. user data:"+JSON.stringify(user));
            Cloud.SocialIntegrations.searchFacebookFriends(function (e){
                if (e.success) {        
                    console.log("searchFacebookFriends successful");
                } else {
                    console.log("searchFacebookFriends not successful");
                    console.log('Error:\n' +
                        ((e.error && e.message) || JSON.stringify(e)));
 
                }
            });
        }
    });         
};
 
 
var userData = {
    username: "test",
    password: "test",
    password_confirmation: "test"
};              
Cloud.Users.create(userData, function (e) {
    if (e.success) {
        console.log('registration successful');
        var user = e.users[0];
        facebook.addEventListener('login', onFacebookLogin);
        facebook.initialize(1000);
        facebook.authorize();
    } else {
        console.log('registration not successful');
    }
});
tiapp.xml
<ios>
        <plist>
            <dict>
                 <key>CFBundleURLTypes</key>
                <array>
                    <dict>
                        <key>CFBundleURLName</key>
                        <!-- Application ID same as the id value in the tiapp.xml file -->
                        <string>com.changemystyle.mathhero</string>
                        <key>CFBundleURLSchemes</key>
                        <array>
                            <!-- Prefix the Facebook App ID with 'fb' -->
                            <string>fb1455001824784603</string>
                        </array>
                    </dict>
                </array>
                <key>FacebookAppID</key>
                <!-- Facebook App ID -->
                <string>1455001824784603</string>
                <key>FacebookDisplayName</key>
                <!-- Facebook App Name from developer.facebook.com -->
                <string>Math Hero</string>                
            </dict>
        </plist>
    </ios>
   <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest android:versionCode="5">
            <application>
                <activity android:label="@string/app_name"
                    android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
                <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
            </application>
        </manifest>
    </android>
console output
[INFO] :   registration successful
[INFO] :   onFacebookLogin
[INFO] :   accountlink successful. user data:{"id":"551415257eead20586b17ba7","created_at":"2015-03-26T14:18:13+0000","updated_at":"2015-03-26T14:18:14+0000","external_accounts":[{"external_id":"10203290489877651","external_type":"facebook","token":"CAAUrUQLp8NsBAC66I6lTa6P5yexeIxkIqOXfnwt2X9ccsEtMktX5K2CRGQKDvLB9RRofzZBHfTeROzshoeYvqJ86Vd7BnTofk8ZCQiQBZCUzX9ybl5J61GPHUr9WAxVlKPKrGZACxfuGWHF6ajebpo5MVcAD3hGQ5jT4OwoV8ManZA2LXe7mopwHbpvWBCITMwJkI0iEUL12Ws9ZBVmFADDrhSZA0mhiZBZCJVSr9ZCxrMzgZDZD"}],"confirmed_at":"2015-03-26T14:18:13+0000","username":"test","email":"","admin":"false","stats":{"photos":{"total_count":0},"storage":{"used":0}},"friend_counts":{"requests":0,"following":0,"friends":0,"followers":0}}
[INFO] :   searchFacebookFriends not successful
[INFO] :   Error:
[INFO] :   User is not authorized with facebook

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>