CMS365.FacebookSharp
6.17.2
See the version list below for details.
dotnet add package CMS365.FacebookSharp --version 6.17.2
NuGet\Install-Package CMS365.FacebookSharp -Version 6.17.2
<PackageReference Include="CMS365.FacebookSharp" Version="6.17.2" />
paket add CMS365.FacebookSharp --version 6.17.2
#r "nuget: CMS365.FacebookSharp, 6.17.2"
// Install CMS365.FacebookSharp as a Cake Addin #addin nuget:?package=CMS365.FacebookSharp&version=6.17.2 // Install CMS365.FacebookSharp as a Cake Tool #tool nuget:?package=CMS365.FacebookSharp&version=6.17.2
FacebookSharp: A .NET library for Facebook Graph API.
FacebookSharp is a .NET library that enables you to authenticate and make graph API calls to Facebook. It's used for posting feeds and contents on Facebook using C# and .NET
Installation
FacebookSharp is available on NuGet. Use the package manager console in Visual Studio to install it:
Install-Package CMS365.FacebookSharp
API support
FacebookSharp version (.NET version) | Facebook Graph API version | Build versions |
---|---|---|
6 | 17 | x |
FacebookSharp currently supports the following Facebook Graph APIs:
- Getting started
- Access & Security
- Using the FacebookSharp
Creating an App
Please visit https://developers.facebook.com/apps and create an app.
Authorization and authentication
Please visit https://developers.facebook.com/tools/explorer/ and generate a user token.
You can adjust permissions based on your needs. This is a short lived token and can be used for Facebook Graph api for user level operations. We will use it to generate a long live user token.
User postman and send a request to the following endpoint and get a long lived user token.
https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=APP_CLIENT_ID&client_secret=APP_CLIENT_SECRET&fb_exchange_token=YOUR_SHORT_LIVED_USER_TOKEN_HERE
You will get a response like
{
"access_token": "vMF7UXNvRZC6m58zr0tRQJP3MVCZBd6JDhHkyCXjWcfag8hfcmjImn85B2YPZAUYK4eirj9ZA0ZAsp1TocZD",
"token_type": "bearer",
"expires_in": 5182228
}
We will get an access_token which is along lives user token and can be used for Facebook Graph api for user level operations but we to generate a page token so that we can perform action on a Facebook page.
https://graph.facebook.com/FACEBOOK_PAGE_ID?fields=access_token&access_token=LONG_LIVED_USER_TOKEN
{
"access_token": "EAASZAbmgGb7YBAFWM3uNUKan1ZBTf4rIAQiLzPSNMa7Lm3Ak1R8tNAVwsORl0LZAcPNEURzFgl6",
"id": "111444904022049"
}
We have now got a page token which we will use to perform action on a Facebook page.
Using the FacebookSharp
Initialize the instance with the page token
var facebookController = new FacebookSharp.FacebookController("EAASZAbmgGb7YBAFWM3uNUKan1ZBTf4rIAQiLzPSNMa7Lm3Ak1R8tNAVwsORl0LZAcPNEURzFgl6");
Page
Get page details
var pageDetail = await facebookController.GetPageDetailsAsync("[PAGE_ID]");
Post with multiline text and images
var pageDetails = await facebookController.PostFeedAsync("[PAGE_ID]", new FacebookSharp.Entities.PageFeedRequestContent()
{
MessageLines = new List<string>() { "Loose Mineral Foundation Shade", "https://google.com","$20" },
PhotoUrls= new List<string>() { "https://cdn.pixabay.com/photo/2017/09/01/00/15/png-2702691_640.png" }
});
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
- RestSharp (>= 110.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.