playMaker

Author Topic: Friendslist - Facebook / androidNative  (Read 1060 times)

Phuzz

  • Full Member
  • ***
  • Posts: 101
    • Bzilla Games
Friendslist - Facebook / androidNative
« on: November 19, 2017, 04:10:25 PM »
Hello,

I am using Facebook Playmaker actions that come with Android Native Plugin, I am adding some of my own actions to expand the possibilities for Playmaker users with Facebook. I got some actions working well, but since I am not an actual coder, I stutter when it gets to Arrays in custom actions. Here is my code:

Code: [Select]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Facebook.MiniJSON;

namespace HutongGames.PlayMaker.Actions {

[ActionCategory("Android Native - Social")]
public class AN_FBGetFriendsList : FsmStateAction {

[Tooltip("The list of friends")]
[UIHint(UIHint.Variable)]
[ArrayEditor(VariableType.String)]
public FsmArray FriendsList;

public FsmInt limit;
public FsmEvent Success;
public FsmEvent Fail;

public override void Reset()
{
FriendsList = null;
limit = null;
}
public override void OnEnter ()
{

SPFacebook.OnFriendsDataRequestCompleteAction += OnFriendsDataLoaded;
SPFacebook.Instance.LoadFrientdsInfo (limit.Value);

}

private void OnFriendsDataLoaded (FB_Result res)
{
SPFacebook.OnFriendsDataRequestCompleteAction -= OnFriendsDataLoaded;

if (res.Error == null) {
//friednds data available, we can get it using
//SPFacebook.instance.friendsList getter
//and we can also use FacebookUserInfo methods, for exmple download user avatar image
List<string> _result = new List<string>();

foreach (FB_UserInfo friend in SPFacebook.Instance.friendsList) {


{
_result.Add(friend.RawJSON);
}

FriendsList.Resize(_result.Count);
FriendsList.Values = _result.ToArray();

}

Fsm.Event (Success);
Finish ();

} else {
Debug.Log ("Opps, friends data load failed, something was wrong");
}
Fsm.Event (Fail);
Finish ();

}

}
}


I might be far off or close I have no Idea, I want to be able to get json data of each user on my friends list and store it in an array.  I got some snippets from the Photon Networking Playmaker Online friends action, since that one adds the friends to an array, Please any help would be much appreciated.

thank you
Bzilla Games "Education with a Tickle!"
Qbucket Games "Voxel Games"