[SOLVED][SDKBOX][FACEBOOK] Need help in getting friendlist

I wanted to integrate facebook in my game. So I tested with the sample project and I got the output… So I integrated facebook in my game and used the same code that is in sample project … I was able to invite friends but fetchfriends is not working . I’m not ale to get details about my friends… I have used “sdkbox.PluginFacebook.getFriends()” and assigned it to a variable… gave a log to check the length and the output was 0…why am I not able to retrieve friend list??
Here’s my code:

   sdkbox.PluginFacebook.init();
   sdkbox.PluginFacebook.setListener({
   onLogin: function(isLogin, msg) {
   if(isLogin){
   self.showText("login successful");
  cc.log("logg",isLogin)
    }
      else {
            self.showText("login failed");
	cc.log("login failed",isLogin)
          }
        },
        onAPI: function(tag, data) {
          cc.log("============");
          cc.log("tag=%s", tag);
          cc.log("data=%s", data);
          if (tag == "me") {
            var obj = JSON.parse(data);
            self.showText(obj.name+ "||" +obj.email+ "||" );
			 url = obj.picture.data.url
	url = url.replace(/\\/g,"");
	url = url.replace("s","");
	self.showText(""+url);
	imageurl=String  (url);		
	cc.textureCache.addImageAsync(imageurl, self.imgdisp, self);

			
   // cc.log("objest pictureeeee",url)
          } else if (tag == "/me/friends") {
            var obj = JSON.parse(data);
            var friends = obj.data;
	cc.log("consoe friens",obj.data)
            for (var i = 0; i < friends.length; i++) {
              cc.log("id %s", friends[i].id);
            }
          } else if (tag == "__fetch_picture_tag__") {
            var obj = JSON.parse(data);
            var url = obj.data.url;
            cc.log("get friend's profile picture=%s", url);
            //self.iconSprite.updateWithUrl(url);
          }
        },
       onPermission: function(isLogin, msg) {
          if(isLogin) {
            self.showText("request permission successful");
          }
          else {
            self.showText("request permission failed");
          }
        },
        onFetchFriends: function(ok, msg) {
          self.showText(ok + ":"+msg, "onFetchFriends"); 
    var friends = sdkbox.PluginFacebook.getFriends();
  cc.log("fetch friendss",friends)
       cc.log("message on fetch",ok,msg,friends.length)
          self.menu.removeAllChildren();
          self.menu.cleanup();
         
          for (var i = 0; i < friends.length; i++) {
            var friend = friends[i];
			
            cc.log("-----------");
            cc.log(">> uid=%s", friend.uid);
            cc.log(">> name=%s", friend.name);
            cc.log(">> first name=%s", friend.firstName);
            cc.log(">> last name=%s", friend.lastName);
            cc.log(">> is installed=%s", friend.isInstalled);

            var foo = ( function() {
                var uid = friend.uid;
                return {
             onClick: function () {
              var params = new Object();
              params.redirect = "false";
            params.type = "small";
 sdkbox.PluginFacebook.api(uid+"/picture", "GET", params, "__fetch_picture_tag__");
                    }
                };
            } () );

            // create menu
            var label = cc.Label.createWithSystemFont(friend.name, "sans", 20);
            var item = new cc.MenuItemLabel(label, foo.onClick);
            self.menu.addChild(item);

            if (friends.length <= 0) {
              self.showText("You don't have any friend on this app", "onFetchFriends");
            }
          }
          self.menu.alignItemsHorizontally();

        },
		onInviteFriendsResult:function(result, msg){
			if(result){
				
				 self.showText("invite successful");
			}
			else{
				self.showText("invite unsuccessful");
			}
				
			
			//self.showText(""+result+""+msg)
			
			
		},
	
    });

    var btnLogin = new cc.MenuItemFont("Login", function(){
      sdkbox.PluginFacebook.login();
    }, this);

    var btnLogout = new cc.MenuItemFont("Logout", function(){
      sdkbox.PluginFacebook.logout();
    }, this);

    var btnCheck = new cc.MenuItemFont("Check", function(){
      cc.log("==============")
      cc.log("isLogin: " + sdkbox.PluginFacebook.isLoggedIn());
      cc.log("userid: " + sdkbox.PluginFacebook.getUserID());
      cc.log("permissions: ");
      var perms = sdkbox.PluginFacebook.getPermissionList();
      for (var i = 0; i < perms.length; i++) {
        cc.log("===> " + perms[i]);
      }
      cc.log("==============")
    }, this);

    var btnReadPerm = new cc.MenuItemFont("Read Perm", function(){
      sdkbox.PluginFacebook.requestReadPermissions(["public_profile", "email","user_friends"]);
    }, this);

    var btnWritePerm = new cc.MenuItemFont("Write Perm", function(){
      sdkbox.PluginFacebook.requestPublishPermissions(["publish_actions"]);
    }, this);

 
         var btnInvite = new cc.MenuItemFont("Invite", function () {
		/* var params = new Object();
      params.fields = "name,email,picture";
		sdkbox.PluginFacebook.requestInvitableFriends(params);*/
      sdkbox.PluginFacebook.inviteFriends(
        // "https://fb.me/322164761287181",
        "https://fb.me/183358042114760",
        "http://lh3.googleusercontent.com/KmXymZoxwyohXuVLiZUyTpMhVSPBSBVEefLA2Lmj2hIf1kGaKIU-htcpSu-wNGtExDBy=w300");
    }, this);


    var btnFetchFriends = new cc.MenuItemFont("Fetch friendsss", function () {
     cc.log("friends info");
     var params = new Object();
    params.fields = "name,email";
      sdkbox.PluginFacebook.api("/me/friends", "GET", params, "/me/friends");
      sdkbox.PluginFacebook.fetchFriends();
	  
    },this);

and the log which I got for the above code:

    D/cocos2d-x debug info(32496): JS: true:[]
    D/cocos2d-x debug info(32496): JS: fetch friendss
    D/cocos2d-x debug info(32496): JS: message on fetch    true    []    0
    D/cocos2d-x debug info(32496): JS: ============
    D/cocos2d-x debug info(32496): JS: tag=/me/friends
    D/cocos2d-x debug info(32496): JS: data={"summary":{"total_count":6},"data":[],"__debug__": 
    {"messages":[{"type":"info","message":"Only friends who installed this app are returned in API v2.0 and 
    higher. total_count in summary represents the total number of friends, including those who haven't 
   installed the app.","link":"https:\/\/developers.facebook.com\/docs\/apps\/changelog#v2_0"}]}}
    D/cocos2d-x debug info(32496): JS: consoe friens  

Can someone help me with this?

1 Like

Can you try add some friend account as testers and see if you can fetch them.

I have added three friends as testers and when I send invite for all the three… only one person gets the invite…remaining don’t get any invites… but I get a message as invite successful…can u help me with this??

@nite it worked…thank you…:relaxed:

@nite
Everything was working fine…all of sudden…i’m getting some error…when I try to invite friends…i’m able to select friends and when i click on send …it just stay still…

      E/InputDispatcher( 5836): Motion event has invalid pointer count 0; value must be between 1 and 16.
      E/InputDispatcher( 5836): Motion event has invalid pointer count 0; value must be between 1 and 16.
      E/InputDispatcher( 5836): Motion event has invalid pointer count 0; value must be between 1 and 16.
      E/InputDispatcher( 5836): Motion event has invalid pointer count 0; value must be between 1 and 16.
      I/chromium(17186): [INFO:CONSOLE(143)] "Uncaught TypeError: Object #<Object> has no   method 'normalizeError'", source: https://m.facebook.com/connect/dialog/MPlatformAppInvitesJSDialog?app_id=1867009130196641&method_args=%7B%22app_link_url%22%3A%22https%3A%5C%2F%5C%2Ffb.me%5C%2F1867013503529537%22%2C%22preview_image_url%22%3A%22https%3A%5C%2F%5C%2Flh3.googleusercontent.com%5C%2Ftwu5QUoX9CVe9HpggfPkvh_6HX9i-mlRzN4hPG455BiQ1cIXKx7lTejLn7UKGDchWwfr%3Dw300-rw%22%7D&bridge_args=%7B%22action_id%22%3A%22eb73626a-2ac3-4e89-8033-8ae3d10b2221%22%7D&display=touch&android_key_hash=nS12lTV0beDYfo2tMez_R4v9AGk%0A (143)

can you please help me with this??

If you sure you didn’t change any code, this could be a facebook issue. See if it gets resolved in 1 hr.

Its been more than an hour and I’m still getting the same issue…

Are you still having this issue? based on your log the error is coming from the web browser (not your app) that’s why I suspect it’s a facebook website issue.

@nite
Yes… As you said it was a facebook issue…
I wanna know something…Is it possible to get the list of friends we have invited??
Is it possible to remove the details of users/friends who has installed the app??

@nite
Facebook is crashing after updating sdkbox. I didn’t change with any code… just updated sdkbox…getting a log as App Ids cannot be directly placed in the manifest.They must be prefixed by ‘fb’ or be placed in the string resource file.

Here’s the log

   E/InputDispatcher(26723): Motion event has invalid pointer count 0; value must be between  1   and 16.
   E/InputDispatcher(26723): Motion event has invalid pointer count 0; value must be between 1 and 16.
   I/FFMPEG  (25561): Last message repeated 1 times
   I/FFMPEG  (25561): [mp3 @ 0x78bd1400] Estimating duration from bitrate, this may be inaccurate
   D/audio_hw_primary(25561): found out /dev/snd/pcmC0D0p
   W/audio_hw_primary(25561): out_write() limiting sleep time 132539 to 46439
   D/cocos2d-x debug info( 8220): JS: seccccccccccccccccccccccccccccccccccccccc    57    39    0
   I/SDKBOX_CORE( 8220): Initialization request for plugin: 'com/sdkbox/plugin/PluginFacebook'
  W/System.err( 8220): App Ids cannot be directly placed in the manifest.They must be prefixed by 'fb' or   be placed in the string resource file.
  W/System.err( 8220):    at com.facebook.FacebookSdk.loadDefaultsFromMetadata(FacebookSdk.java:638)
  W/System.err( 8220):    at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:207)
  W/System.err( 8220):    at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:177)
  W/System.err( 8220):    at com.sdkbox.plugin.PluginFacebook.configure(PluginFacebook.java:115)
  W/System.err( 8220):    at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native Method)
  W/System.err( 8220):    at org.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:91)
  W/System.err( 8220):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523)
  W/System.err( 8220):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
  E/Facebook( 8220): Facebook don't support 'setAppURLSchemeSuffix' on android
  F/libc    ( 8220): Fatal signal 11 (SIGSEGV) at 0x2f0c5e5c (code=1), thread 8240 (Thread-837)
  W/audio_hw_primary(25561): out_write() limiting sleep time 95759 to 46439
  W/audio_hw_primary(25561): out_write() limiting sleep time 68979 to 46439
  I/DEBUG   (  590): pid: 8220, tid: 8240, pkg name: com.infocom.BlackJack21Pontoon
  I/DEBUG   (  590): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  I/DEBUG   (  590): Build fingerprint: 'samsung/kltexx/klte:4.4.2/KOT49H/G900FXXU1ANCE:user/release-keys'
  I/DEBUG   (  590): Revision: '0'
  I/DEBUG   (  590): pid: 8220, tid: 8240, name: Thread-837  >>> com.infocom.BlackJack21Pontoon <<<
  I/DEBUG   (  590): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 2f0c5e5c
  I/DEBUG   (  590):     eax 2f0c5e5c  ebx 74ea7cb0  ecx 65047400  edx 00000000
 W/NativeCrashListener(26723): Couldn't find ProcessRecord for pid 1885955130
 I/DEBUG   (  590): AM write failure (32 / Broken pipe)
 I/DEBUG   (  590):     esi 2f0c5e5c  edi f8a647bc
 I/DEBUG   (  590):     xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000043  xss 0000007b
  I/DEBUG   (  590):     eip 74d7dfd4  ebp 53a77fcb  esp 53b87430  flags 00210207
  I/DEBUG   (  590):
 I/DEBUG   (  590): backtrace:
  I/DEBUG   (  590):     #00  pc 0009cfd4  /system/lib/libdvm.so (dvmCreateCstrFromString(StringObject const*)+68)
   I/DEBUG   (  590):     #01  pc 0007ea39  /system/lib/libdvm.so
  I/DEBUG   (  590):     #02  pc 001997ae  /system/lib/lib3btrans.so
  I/DEBUG   (  590):
  I/DEBUG   (  590): stack:
  I/DEBUG   (  590):          53b873f0  77ffc5e0  [heap]
  I/DEBUG   (  590):          53b874d4  776f36a8
  I/DEBUG   (  590):          53b874d8  77665ddf  /system/lib/libc.so (dlmalloc+351)
  I/BootReceiver(26723): Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
 D/dalvikvm(26723): GC_FOR_ALLOC freed 2184K, 22% free 16545K/21200K, paused 20ms, total 20ms
 D/BstCommandProcessor-Application(26954): Application crash has been observed.
 D/dalvikvm(26723): GC_FOR_ALLOC freed 931K, 24% free 16121K/21200K, paused 30ms, total 30ms

and my AndroidManifest file:

    <?xml version='1.0' encoding='UTF-8'?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"        package="com.infocom.BlackJack21Pontoon" android:installLocation="auto" android:versionCode="1"        android:versionName="1.0">
   <uses-sdk android:minSdkVersion="9" />
<uses-feature android:glEsVersion="0x00020000" />
<application hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
    <meta-data android:name="android.app.lib_name" android:value="cocos2djs" />
    <activity android:configChanges="orientation" android:label="@string/app_name" android:name="org.cocos2dx.javascript.AppActivity" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.Translucent" />
    <activity android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" android:name="com.facebook.FacebookActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:resource="@string/fb_app_id" />
    <provider android:authorities="com.facebook.app.FacebookContentProvider1322042141180744" android:exported="true" android:name="com.facebook.FacebookContentProvider" />
</application>
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING" />

Please double check your AndroidManifest.xml and strings.xml make sure your facebook id is entered correctly.

I have checked and my facebook id is correct. It was working well with previous version of sdkbox and i’m using the same code that I used before… I didn’t do any changes in code…I just updated sdkbox…