发布时,给定的密钥在字典中不存在 [英] The given key was not present in the dictionary when posting

查看:110
本文介绍了发布时,给定的密钥在字典中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

i需要任何曾经做过的人的帮助,并在尝试使用这个API时解决了这个问题,并且得到了一个错误的给定密钥不存在...



i在尝试发布到Facebook时间线时出错。,accessstoken和facebookid已经存储在数据库中。



和这是代码



hello,
i need help from anyone that has ever done and solved the problem when trying to use this API, and got an error of The Given Key Was Not Present...

i got an error when trying post to facebook timeline., the accesstoken, and facebookid already store in database.

and here is the code

public void SendComment(string p_strIdFB, string p_strMessage, string p_strWebLink, string p_strLinkAlias, 
            string p_strCaption, string p_strDescription, string p_strPictLink, string p_strIconLink, string p_strIdgods)
        {
            
            //FacebookSettings set = new FacebookSettings();
            //set.AppId = v_strApiKey;
            //set.AppSecret = v_strApiSecret;

            try
            {
                IDictionary<string, object> dict = new Dictionary<string, object>();
                dict.Add("message", p_strMessage);
                if (ConverterManager.ConvertEmptyTextIntoString(p_strWebLink, "") != "")
                {
                    dict.Add("link", p_strWebLink);
                    if (ConverterManager.ConvertEmptyTextIntoString(p_strPictLink, "") != "")
                    {
                        dict.Add("picture", p_strPictLink);
                    }
                    if (ConverterManager.ConvertEmptyTextIntoString(p_strLinkAlias, "") != "")
                    {
                        dict.Add("name", p_strLinkAlias);
                    }
                    if (ConverterManager.ConvertEmptyTextIntoString(p_strCaption, "") != "")
                    {
                        dict.Add("caption", p_strCaption);
                    }
                    if (ConverterManager.ConvertEmptyTextIntoString(p_strDescription, "") != "")
                    {
                        dict.Add("description", p_strDescription);
                    }
                }
                if (ConverterManager.ConvertEmptyTextIntoString(p_strIconLink, "") != "")
                {
                    dict.Add("icon", p_strIconLink);
                }

                //FacebookApp app = new FacebookApp(set);
                //app.Api("me/feed", dict, HttpMethod.Post);

                string idgods = "";
                idgods = p_strIdgods;
                BLGodsProfile objBLGodsProfile = new BLGodsProfile();
                tbmgodsprofile objGods = objBLGodsProfile.GetAccessToken(idgods);

                //FacebookWebClient fwc = new FacebookWebClient();
                var fwc = new FacebookClient(objGods.accesstoken);
                FacebookWebClient ff = new FacebookWebClient(objGods.accesstoken);

                ff.Post("/" + objGods.iduserfb + "/feed", dict);
            }
            catch(Exception ex)
            {
                Console.WriteLine("This User : {0} Got Error Posting Facebook : {1}",p_strIdgods, ex.Message);
            }
            
            
        }





这里是将其发布到的代码facebook



and here is the code to posting it to facebook

private static void PostShoutToFb1(string p_strMessage, string idgods)
    {
        BLFb objBLFb = new BLFb(System.Configuration.ConfigurationManager.AppSettings["FbApiKey"],
                                System.Configuration.ConfigurationManager.AppSettings["FbApiSecret"]);
        TdoFacebookUser objFbUser = objBLFb.GetFacebookUser();

        try
        {
            //objBLFb.SendComment(objFbUser.Id, p_strMessage, "", "", "", "", "", "", idgods);
            objBLFb.comment(p_strMessage,idgods);
        }
        catch(Exception ex)
        {
            LogException(ex, "GodsFeed");
        }
    }



trims


trims

推荐答案

我找到了答案,这是我没有管理和连接我的Facebook与我的应用程序。

为某人有错误代码,你需要检查登录facebook的范围。 {scope:..}那个。



谢谢:D
i've found the answer, it's was i haven't manage and connect my facebook with my apps.
for someone has the error code, you need to check the scope of login facebook. {scope : ..} that one.

thanks :D


这篇关于发布时,给定的密钥在字典中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆