コード例 #1
0
        /*ServerStream FbFeedStreamWaiting = null;
         * static void feed(ServerStream svstream) {
         *  if (FacebookClient.Instance.Token.Length > 0 && FbFeedStreamWaiting == null) {
         *      StreamBuffer buf = new StreamBuffer(svstream.PostData);
         *      string message = buf.readSStr();
         *      FbFeedStreamWaiting = svstream;
         *      FacebookClient.Instance.PostMessageOnWall(AppObject.GameInfo.FacebookFeedTitle,
         *          message,
         *          //AppObject.GameInfo.FacebookFeedAttahLink,
         *          AppObject.AppLink,
         *          AppObject.GameInfo.FacebookFeedImageUrl,
         *          new UploadStringCompletedEventHandler(fb_feed_handle));
         *  } else {
         *      svstream.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR;
         *  }
         * }
         * static private void fb_feed_handle(object sender, UploadStringCompletedEventArgs e) {
         *  if (FbFeedStreamWaiting != null) {
         *      if (e != null && e.Error == null) {
         *          FbFeedStreamWaiting.Status = (int)ServerStreamStatus.STREAM_STATUS_RESPONSED;
         *          //MessageBox.Show("Completed");
         *      } else {
         *          FbFeedStreamWaiting.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR;
         *          //MessageBox.Show("Error! Please retry later");
         *      }
         *      FbFeedStreamWaiting = null;
         *  }
         * }
         * */
        static public void getFriends(Actions.DelegateBegin onBegin, Actions.DelegateDone onDone, Actions.DelegateCancel onCancel)
        {
            Actions.ActionFacebookGetFriendsArg arg             = new Actions.ActionFacebookGetFriendsArg();
            Actions.ActionFacebookGetFriends    action_fbfriend = new Actions.ActionFacebookGetFriends();

            try {
                if (onBegin != null)
                {
                    action_fbfriend.OnBegin += onBegin;
                }
                if (onDone != null)
                {
                    action_fbfriend.OnDone += onDone;
                }
                if (onCancel != null)
                {
                    action_fbfriend.OnCancel += onCancel;
                }
                action_fbfriend.Do(arg);
            } catch (Exception ex) {
                if (onCancel != null)
                {
                    onCancel(null, arg);
                }
            }
        }
コード例 #2
0
        async void loadFriend(ActionFacebookGetFriendsArg arg)
        {
            HttpClient client = new HttpClient();
            string     url    = FacebookClient.Instance.getAppUserUrl();

            try
            {
                string rs = await client.GetStringAsync(new Uri(url));

                arg.FriendIds.Clear();
                var juser = JsonConvert.DeserializeObject <FriendsList>(rs);
                if (juser != null && juser.data.Count > 0)
                {
                    for (int f = 0; f < juser.data.Count; f++)
                    {
                        arg.FriendIds.Add(Int64.Parse(juser.data[f].uid));
                    }
                }
                Done(arg);
            }
            catch (Exception ex)
            {
                Cancel(arg);
            }
        }