Realizing the importance of social media, in the previous blog we learned to integrate twitter to our C#.Net application. We saw “How to post message and image on Twitter”. Now let’s learn how to post messages & images on Facebook account as well as Facebook Page.
How to use to post messages and Images on Facebook Account & Page using ASP.Net C#
For integrating Facebook to your application we need to generate the keys & access token to authenticate the application.
Generate keys & access token
1. Sign In at “https://www.facebook.com” using your Facebook login id.
2. After that browse to the “https://developers.facebook.com” page.
3. Accept it by selecting the option to “YES” in the dialog box opened.
4. After clicking on Register you will get this screen, click on “Done” to continue.
5. After clicking “Done” you will be redirected to this screen, you can develop the app which will be integrated to Facebook. Select the type to app you want to develop.
6. I have used the website as I will be connecting to web app. Create new app as shown in the image.
7. After clicking on “Create New Facebook App ID”, you will get below screen where you have to select the category of your application.
8. After creating App ID, you will get the SDK script as shown below which can be used on page load.
9. After clicking on “Skip Quick Start”, you will be redirected to dashboard.
10. Go to “Tools & Support” menu to retrieve Access Token.
11. Here you will get the User & Application access tokens of you apps created.
12. Click on “need to grant permission” to assign permission to your application and retrieve user access token.
13. You will get the User access token here and you can debug and check if it’s working or expired as shown below.
14. After clicking debug beside “User Token” you will get the access token information as shown below.
15. After clicking debug beside “App Token” you will get App token & its id with name as shown below.
16. Go To “Graph Api Explorer” menu from “Tools & Support” menu and you will get the below screen from which you can user access token & debug it to check if it is valid as well as you can get data, post data or delete the data.
17. You can select the Account/Page from “Get Token” drop down to retrieve its user access token(For first time it will only show Get Access Token and Page Access Token as shown below) you can click here and retrieve the access token.
18. Assign user data permissions and extended permissions as shown below.
19. After clicking get access token you will get the below screen. Click okay and you will get the user access token.
20. Copy the access token and you can use this in your application.
21. Retrieve album id as this will help to retrieve album information as well as you can post photos into this album with the help of this id.
22. Retrieve the account/page id as well as album id of that account/page.
- Select you page
- Retrieve the page id
- Retrieve the desired album id from the page so that you can post photos into that album
Refer the next blog for the code to post message, images and albums on Facebook using above keys access tokens and id’s.