Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

I am currently doing an application which allows users to upload an image to the Facebook Page Album.

This is the code:
C#
if(e.Uri.ToString().StartsWith("http://www.facebook.com/connect/login_success.html"))
{
    AccessToken = e.Uri.Fragment.Split('&')[0].Replace("#access_token=", "");
    MessageBox.Show(AccessToken);
    FBClient = new FacebookClient(AccessToken);
    
    FacebookMediaObject mediaObject = new FacebookMediaObject
    {
        FileName = "photo1",
        ContentType = "image/jpeg"
    };

    var bytes = System.IO.File.ReadAllBytes("C:\\Users\\user\\Downloads\\WpfCloud\\WpfCloud\\WpfCloud\\photo1.jpg");
    mediaObject.SetValue(bytes);

    var postInfo = new Dictionary<string,>();
    postInfo.Add("message", "MD ALIF");
    postInfo.Add("image", mediaObject);

    FBClient.Post("/" + "1561850604041740" +  "/photos", postInfo);
}

But at the last line "FBClient.Post("/" + "1561850604041740" + "/photos", postInfo);" I am receiving an error saying that "a user access token is required at this resource".

I am still new to WPF and C# so help needed. Thanks in advance.


[Edit member="Tadit"]
Added pre tags.
[/Edit]
Posted
v2

1 solution

Refer - Access Tokens[^].
 
Share this answer
 
v2

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