Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

C#
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);
            }
            
            
        }


and here is the code to posting it to facebook
C#
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
Posted
Comments
On which line?
Andrew Budiman 1-Jun-14 23:22pm    
this line : objBLFb.SendComment(objFbUser.Id, p_strMessage, "", "", "", "", "", "", idgods);

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900