Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to pass the Image in a POST request to the Graph API (Need publish_stream permission). What is mentioned in Facebook Documentation is correct. Following is the example code that may do the work. use it inside a method. (Code is in C#)</p> <p><strong>Legend</strong> <code>&lt;content&gt;</code> : you need to provide the info.</p> <p><strong>Update</strong> Please post comments to improve the code.</p> <pre><code>string ImageData; string queryString = string.Concat("access_token=", /*&lt;Place your access token here&gt;*/); string boundary = DateTime.Now.Ticks.ToString("x", CultureInfo.InvariantCulture); StringBuilder sb = String.Empty; sb.Append("----------").Append(boundary).Append("\r\n"); sb.Append("Content-Disposition: form-data; filename=\"").Append(/*&lt;Enter you image's flename&gt;*/).Append("\"").Append("\r\n"); sb.Append("Content-Type: ").Append(String.Format("Image/{0}"/*&lt;Enter your file type like jpg, bmp, gif, etc&gt;*/)).Append("\r\n").Append("\r\n"); using (FileInfo file = new FileInfo("/*&lt;Enter the full physical path of the Image file&gt;*/")) { ImageData = file.OpenText().ReadToEnd(); } byte[] postHeaderBytes = Encoding.UTF8.GetBytes(sb.ToString()); byte[] fileData = Encoding.UTF8.GetBytes(ImageData); byte[] boundaryBytes = Encoding.UTF8.GetBytes(String.Concat("\r\n", "----------", boundary, "----------", "\r\n")); var postdata = new byte[postHeaderBytes.Length + fileData.Length + boundaryBytes.Length]; Buffer.BlockCopy(postHeaderBytes, 0, postData, 0, postHeaderBytes.Length); Buffer.BlockCopy(fileData, 0, postData, postHeaderBytes.Length, fileData.Length); Buffer.BlockCopy(boundaryBytes, 0, postData, postHeaderBytes.Length + fileData.Length, boundaryBytes.Length); var requestUri = new UriBuilder("https://graph.facebook.com/me/photos"); requestUri.Query = queryString; var request = (HttpWebRequest)HttpWebRequest.Create(requestUri.Uri); request.Method = "POST"; request.ContentType = String.Concat("multipart/form-data; boundary=", boundary); request.ContentLength = postData.Length; using (var dataStream = request.GetRequestStream()) { dataStream.Write(postData, 0, postData.Length); } request.GetResponse(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload