我想在用户个人资料上上传图片。我有一个Bitmap
形式的图像。我正在使用此代码...
Bitmap bit = new Bitmap("E:\\abc.jpg");
MemoryStream ms = new MemoryStream();
bit.Save(ms, ImageFormat.Jpeg);
byte[] buffer = ms.ToArray();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://graph.facebook.com/me/photos?access_token=" + acc_token);
req.Method = "POST";
req.ContentLength = buffer.Length;
//req.ContentType = "application/x-www-form-urlencoded";
req.ContentType = "image/jpeg";
Stream rq_strm = req.GetRequestStream();
rq_strm.Write(buffer, 0, buffer.Length);
rq_strm.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse(); //got error here
Response.Write("RESPONSE: " + res.StatusDescription);
我收到错误The remote server returned an error: (400) Bad Request.
我错在哪里?