Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir, i want to post status and photo on my facebook wall using my aspx webform. i am trying some codes but all are gives an error.

What I have tried:

protected void Page_Load(object sender, EventArgs e)
   {
       FaceBookConnect.API_Key = "xxxxxxxxxxxxxxxx";
       FaceBookConnect.API_Secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
       if (!IsPostBack)
       {
           string code = Request.QueryString["code"];
           if (!string.IsNullOrEmpty(code))
           {
               FaceBookConnect.PostFile(code, "me/photos", (HttpPostedFile)Session["File"], Session["Message"].ToString());
               Session["File"] = null;
               Session["Message"] = null;
           }
       }
   }

   protected void UploadPhoto(object sender, EventArgs e)
   {
       Session["File"] = FileUpload1.PostedFile;
       Session["Message"] = txtMessage.Text;
       FaceBookConnect.Authorize("user_photos", Request.Url.AbsoluteUri.Split('?')[0]);
   }



i am getting this error on
FaceBookConnect.PostFile
line.
The remote server returned an error: (400) Bad Request.
Posted
Updated 10-Jul-18 19:51pm

1 solution

(400) Bad Request is the web equivalent of Syntax Error. The inner exception usually has more information on what failed.

Documentation for posting to FB can be found here: Posting to a Page[^]

Have you authenticated[^] and met all the requirements[^] for posting?
 
Share this answer
 
Comments
TCS54321 19-Jul-18 0:25am    
basically i am on development face. and run my application on localhost. i have no idea how can i request to facebook to approve manage_pages and publish_pages permissions. because i think this two permission is necessary to post on facebook by third party application.
Graeme_Grant 19-Jul-18 2:21am    
That is a matter that you need to discuss with them.

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