Facebook API publish post with image

, and then I worked on the ASPSnippets FaceBook API to add functionality to upload photos, pictures or images to FaceBook wall

Note: You can download the latest ASPSnippets.FaceBookAPI.dll clicking the download link below.

          Download DLL file

 

More FaceBook Articles

ASP.Net Get FaceBook User details like Gender, Email, Address Location and Birth Date

Import FaceBook Album Photos and display as Image Gallery in ASP.Net

Login with FaceBook account in ASP.Net Website

Post Publish and Share content on user’s FaceBook Wall using Graph API in ASP.Net

FaceBook - Get Full size Profile Picture of user in ASP.Net using C# and VB.Net

 

Facebook API publish post with image



 

Create FaceBook Application and get App Id

You will need to create an application and get an API Key and API Secret. You can refer my article

Create FaceBook App and Facebook Application Id ( AppId ) and Secret Key

 

 

HTML Markup

The HTML Markup is simple it consist of an ASP.Net FileUpload control, a Multiline TextBox and a Button.

<asp:FileUpload ID="FileUpload1" runat="server" />

<br />

<br />

<asp:TextBox ID="txtMessage" runat="server" TextMode = "MultiLine"></asp:TextBox>

<hr />

<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick = "UploadPhoto" />

 

 

Namespaces

You will need to import the following namespaces

C#

using ASPSnippets.FaceBookAPI;

 

VB.Net

Imports ASPSnippets.FaceBookAPI

 

 

Upload Photo (Image) to FaceBook Wall

On the click of the button the UploadPhoto event handler is raised which sets the uploaded file and the message in the Session variable and then redirects user to FaceBook site to fetch the Access Code.

The FaceBook site redirects back to the page with the access code and then the File and the Message are posted on to the FaceBook wall using the FaceBookConnect PostFile method.

I want to upload a series of images to Facebook and group them together in a single post. Right now I’m able to upload the pictures without any problems, but the pictures are publish in single posts each one of them.

I followed this guide from the developers documentation, but still no success on grouping all the images in a single posts.

I’m first uploading the pictures with “published → false” on the “/photos” endpoint and after that I get the ID’s and send each one to the endpoint “/feed”.

Facebook's application programming interface lets you create apps to maintain your business' group page without sitting down at a computer and logging into the social networking site. Using this API you can customize applications to desktop or mobile platforms for publishing pictures to your group page at any pace your company needs. The process involves authenticating the program with the Facebook API, authenticating picture publishing permissions with your business's account, then sending post requests via HTTP to Facebook's servers.

The Graph

  1. Facebook organizes all of its data into what it calls the social graph. Posts and pictures are objects associated with individual users and groups. Facebook's API lets you retrieve these objects from, or post new objects to, this graph. Uploading new pictures to your business's Facebook group is, from a technical standpoint, a matter of sending new pictures to your group's address on the graph API.

Authentication

  1. Facebook does not allow completely anonymous use of the social graph's API. In order to write data to the graph, your program will first have to request an authentication token. You then include this authentication token with all of your HTTP requests for Facebook to carry out your requests. The social graph API uses OAuth for its token authentication services, and the exact process your application will use to authenticate itself through this service depends on the platform with which you are developing. You can consult Facebook's developer resources to find information on obtaining authentication tokens with different development platforms.

App Authentication

  1. Once your program obtains an authentication token, Facebook can identify the program and will allow it to access the social graph. You cannot, however, log in as a particular user with an app. Your app has its own identity on Facebook, and by default it will only be able to access public information or post to completely public walls or albums. If you have restricted the ability to post new photos to your group's albums to group members or group administrators, then you need to make your app send a request to your group for the permission to publish photos to its albums. You will need to log in to Facebook and approve this request yourself.

Posting Picture

  1. Once you have your app appropriately configured and authenticated for posting to your business' group, you will publish pictures by sending HTML POST requests to your group's URL. Your program will direct this post request to "https://graph.facebook.com/album_ID/photos" in which "album_ID" is the ID number Facebook assigned your group's photo album. The post request will include any message or caption you want to include with the picture, the actual image data for the picture itself and any place data you want to include.

    How do I post a photo from Facebook Graph API?

    Step 1: Create a Session.
    Request Syntax. POST https://graph.facebook.com/{api-version}/{app-id}/uploads &file_length={file-length} &file_type={file-type} &access_token={access-token} ... .
    Response. { "id": "{id}" } ... .
    Sample Request. ... .
    Sample Response. ... .
    Request Syntax. ... .
    Response. ... .
    Sample Request. ... .
    Sample Response..

    How do I share a Facebook post with API?

    Yes, you can share using the graph2 api. The way you do it is to use /feed edge and pass the post's url that you want to share as the link. Standard Fb permissions to the post you are sharing do apply. This was done today, in a local rails app, using FbGraph2 gem, with the above method.

    How do I publish a Facebook post?

    Tap in the top right of Facebook. Search for the Page you'd like to post on, then select it from the dropdown menu. Tap Posts, then tap Write something on the Page. Write your post, then tap Publish.

    How do I get Facebook posts on API?

    Show activity on this post..
    /me/feed gives you posts published by this person..
    /me/posts shows only the posts published by this person..
    /me/tagged shows only posts that this person is tagged in..
    Edit : From a user access token, you can only get feed of that user and his facebook friends who are users of this app..