Beispiel #1
0
    public void LoadLikes(string userId, string pageId)
    {
        FBLikesRetrieveTask task = FBLikesRetrieveTask.Create();

        task.addEventListener(BaseEvent.COMPLETE, OnUserLikesResult);
        task.LoadLikes(userId, pageId);
    }
Beispiel #2
0
    public void LoadLikes(string userId, string pageId)
    {
        FBLikesRetrieveTask task = FBLikesRetrieveTask.Create();

        task.ActionComplete += OnUserLikesResult;
        task.LoadLikes(userId, pageId);
    }
Beispiel #3
0
    //--------------------------------------
    //  EVENTS
    //--------------------------------------

    private void OnUserLikesResult(FBResult result, FBLikesRetrieveTask task)
    {
        FB_APIResult r;

        if (result.Error != null)
        {
            r = new FB_APIResult(false, result.Error);
            r.Unity_FB_Result = result;
            OnLikesListLoadedAction(r);
            return;
        }


        Dictionary <string, object> JSON = ANMiniJSON.Json.Deserialize(result.Text) as Dictionary <string, object>;
        List <object> data = JSON["data"]  as List <object>;


        Dictionary <string, FBLikeInfo> userLikes = null;

        if (_likes.ContainsKey(task.userId))
        {
            userLikes = _likes[task.userId];
        }
        else
        {
            userLikes = new Dictionary <string, FBLikeInfo>();
            _likes.Add(task.userId, userLikes);
        }

        foreach (object row in data)
        {
            Dictionary <string, object> dataRow = row as Dictionary <string, object>;

            FBLikeInfo tpl = new FBLikeInfo();
            tpl.id       = System.Convert.ToString(dataRow["id"]);
            tpl.name     = System.Convert.ToString(dataRow["name"]);
            tpl.category = System.Convert.ToString(dataRow["category"]);

            if (userLikes.ContainsKey(tpl.id))
            {
                userLikes[tpl.id] = tpl;
            }
            else
            {
                userLikes.Add(tpl.id, tpl);
            }
        }

        r = new FB_APIResult(true, result.Text);
        r.Unity_FB_Result = result;
        OnLikesListLoadedAction(r);
    }
Beispiel #4
0
    //--------------------------------------
    //  EVENTS
    //--------------------------------------

    private void OnUserLikesResult(CEvent e)
    {
        FBLikesRetrieveTask task = e.dispatcher as FBLikesRetrieveTask;

        task.removeEventListener(BaseEvent.COMPLETE, OnUserLikesResult);

        FBResult result = e.data as FBResult;


        FB_APIResult r;

        if (result.Error != null)
        {
            r = new FB_APIResult(false, result.Error);
            r.Unity_FB_Result = result;
            dispatch(FacebookEvents.LIKES_LIST_LOADED, r);
            OnLikesListLoadedAction(r);
            return;
        }


        Dictionary <string, object> JSON = ANMiniJSON.Json.Deserialize(result.Text) as Dictionary <string, object>;
        List <object> data = JSON["data"]  as List <object>;


        Dictionary <string, FBLikeInfo> userLikes = null;

        if (_likes.ContainsKey(task.userId))
        {
            userLikes = _likes[task.userId];
        }
        else
        {
            userLikes = new Dictionary <string, FBLikeInfo>();
            _likes.Add(task.userId, userLikes);
        }

        foreach (object row in data)
        {
            Dictionary <string, object> dataRow = row as Dictionary <string, object>;

            FBLikeInfo tpl = new FBLikeInfo();
            tpl.id       = System.Convert.ToString(dataRow["id"]);
            tpl.name     = System.Convert.ToString(dataRow["name"]);
            tpl.category = System.Convert.ToString(dataRow["category"]);

            if (userLikes.ContainsKey(tpl.id))
            {
                userLikes[tpl.id] = tpl;
            }
            else
            {
                userLikes.Add(tpl.id, tpl);
            }
        }

        r = new FB_APIResult(true, result.Text);
        r.Unity_FB_Result = result;
        dispatch(FacebookEvents.LIKES_LIST_LOADED, r);
        OnLikesListLoadedAction(r);
    }