當前位置: 首頁>>代碼示例>>C#>>正文


C# AccessToken.ToJson方法代碼示例

本文整理匯總了C#中AccessToken.ToJson方法的典型用法代碼示例。如果您正苦於以下問題:C# AccessToken.ToJson方法的具體用法?C# AccessToken.ToJson怎麽用?C# AccessToken.ToJson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AccessToken的用法示例。


在下文中一共展示了AccessToken.ToJson方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SendSuccessResult

        protected override void SendSuccessResult()
        {
            if (string.IsNullOrEmpty(this.accessToken))
            {
                this.SendErrorResult("Empty Access token string");
                return;
            }

            // Make a Graph API call to get FBID
            FB.API(
                "/me?fields=id&access_token=" + this.accessToken,
               HttpMethod.GET,
               delegate(IGraphResult graphResult)
            {
                if (!string.IsNullOrEmpty(graphResult.Error))
                {
                    this.SendErrorResult("Graph API error: " + graphResult.Error);
                    return;
                }

                string facebookID = graphResult.ResultDictionary["id"] as string;

                // Make a Graph API call to get Permissions
                FB.API(
                    "/me/permissions?access_token=" + this.accessToken,
                   HttpMethod.GET,
                   delegate(IGraphResult permResult)
                {
                    if (!string.IsNullOrEmpty(permResult.Error))
                    {
                        this.SendErrorResult("Graph API error: " + permResult.Error);
                        return;
                    }

                    // Parse permissions
                    List<string> grantedPerms = new List<string>();
                    List<string> declinedPerms = new List<string>();
                    var data = permResult.ResultDictionary["data"] as List<object>;
                    foreach (Dictionary<string, object> dict in data)
                    {
                        if (dict["status"] as string == "granted")
                        {
                            grantedPerms.Add(dict["permission"] as string);
                        }
                        else
                        {
                            declinedPerms.Add(dict["permission"] as string);
                        }
                    }

                    // Create Access Token
                    var newToken = new AccessToken(
                        this.accessToken,
                        facebookID,
                        DateTime.UtcNow.AddDays(60),
                        grantedPerms,
                        DateTime.UtcNow);

                    var result = (IDictionary<string, object>)MiniJSON.Json.Deserialize(newToken.ToJson());
                    result.Add("granted_permissions", grantedPerms);
                    result.Add("declined_permissions", declinedPerms);
                    if (!string.IsNullOrEmpty(this.CallbackID))
                    {
                        result[Constants.CallbackIdKey] = this.CallbackID;
                    }

                    if (this.Callback != null)
                    {
                        this.Callback(new ResultContainer(result));
                    }
                });
            });
        }
開發者ID:Cube219,項目名稱:BlockBuster,代碼行數:73,代碼來源:MockLoginDialog.cs

示例2: SendSuccessResult

        protected override void SendSuccessResult()
        {
            if (string.IsNullOrEmpty(this.accessToken))
            {
                this.SendErrorResult("Empty Access token string");
                return;
            }

            var token = new AccessToken(
                this.accessToken,
                "MockUserId",
                DateTime.Now.AddDays(60),
                this.Permissions);
            var result = (IDictionary<string, object>)MiniJSON.Json.Deserialize(token.ToJson());
            if (!string.IsNullOrEmpty(this.CallbackID))
            {
                result[Constants.CallbackIdKey] = this.CallbackID;
            }

            if (this.Callback != null)
            {
                this.Callback(MiniJSON.Json.Serialize(result));
            }
        }
開發者ID:rdenubila,項目名稱:Uberland,代碼行數:24,代碼來源:MockLoginDialog.cs


注:本文中的AccessToken.ToJson方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。