Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apimatic/whatsapp-dotnet-sdk
https://github.com/apimatic/whatsapp-dotnet-sdk
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/apimatic/whatsapp-dotnet-sdk
- Owner: apimatic
- License: other
- Created: 2022-06-17T07:44:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-17T08:44:29.000Z (over 2 years ago)
- Last Synced: 2024-04-17T07:32:47.877Z (7 months ago)
- Language: C#
- Size: 96.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Getting Started with WhatsApp Cloud API
## Introduction
Welcome to the WhatsApp API from Meta.
Individual developers and existing Business Service Providers (BSPs) can now send and receive messages via the WhatsApp API using a cloud-hosted version of the WhatsApp Business API. Compared to the previous solutions, the cloud-based WhatsApp API is simpler to use and is a more cost-effective way for businesses to use WhatsApp. Please keep in mind the following configurations:
| Name | Description |
| --- | --- |
| Version | Latest [Graph API version](https://developers.facebook.com/docs/graph-api/). For example: v13.0 |
| User-Access-Token | Your user access token after signing up at [developers.facebook.com](https://developers.facebook.com). |
| WABA-ID | Your WhatsApp Business Account (WABA) ID. |
| Phone-Number-ID | ID for the phone number connected to the WhatsApp Business API. You can get this with a [Get Phone Number ID request](3184f675-d289-46f1-88e5-e2b11549c418). |
| Business-ID | Your Business' ID. Once you have your Phone-Number-ID, make a [Get Business Profile request](#99fd3743-46cf-46c4-95b5-431c6a4eb0b0) to get your Business' ID. |
| Recipient-Phone-Number | Phone number that you want to send a WhatsApp message to. |
| Media-ID | ID for the media to [send a media message](#0a632754-3788-43bf-b785-ac6a73423d5a) or [media template message](#439c926a-8a6c-4972-ab2c-d99297716da9) to your customers. |
| Media-URL | URL for the media to [download media content](#cbe5ece3-246c-48f3-b338-074187dfef66). |## Building
The generated code uses the Newtonsoft Json.NET NuGet Package. If the automatic NuGet package restore is enabled, these dependencies will be installed automatically. Therefore, you will need internet access for build.
* Open the solution (WhatsAppCloudAPI.sln) file.
Invoke the build process using Ctrl + Shift + B shortcut key or using the Build menu as shown below.
The build process generates a portable class library, which can be used like a normal class library. The generated library is compatible with Windows Forms, Windows RT, Windows Phone 8, Silverlight 5, Xamarin iOS, Xamarin Android and Mono. More information on how to use can be found at the MSDN Portable Class Libraries documentation.
## Installation
The following section explains how to use the WhatsAppCloudAPI.Standard library in a new project.
### 1. Starting a new project
For starting a new project, right click on the current solution from the solution explorer and choose `Add -> New Project`.
![Add a new project in Visual Studio](https://apidocs.io/illustration/cs?workspaceFolder=WhatsApp%20Cloud%20API-CSharp&workspaceName=WhatsAppCloudAPI&projectName=WhatsAppCloudAPI.Standard&rootNamespace=WhatsAppCloudAPI.Standard&step=addProject)
Next, choose `Console Application`, provide `TestConsoleProject` as the project name and click OK.
![Create a new Console Application in Visual Studio](https://apidocs.io/illustration/cs?workspaceFolder=WhatsApp%20Cloud%20API-CSharp&workspaceName=WhatsAppCloudAPI&projectName=WhatsAppCloudAPI.Standard&rootNamespace=WhatsAppCloudAPI.Standard&step=createProject)
### 2. Set as startup project
The new console project is the entry point for the eventual execution. This requires us to set the `TestConsoleProject` as the start-up project. To do this, right-click on the `TestConsoleProject` and choose `Set as StartUp Project` form the context menu.
![Adding a project reference](https://apidocs.io/illustration/cs?workspaceFolder=WhatsApp%20Cloud%20API-CSharp&workspaceName=WhatsAppCloudAPI&projectName=WhatsAppCloudAPI.Standard&rootNamespace=WhatsAppCloudAPI.Standard&step=setStartup)
### 3. Add reference of the library project
In order to use the Tester library in the new project, first we must add a project reference to the `TestConsoleProject`. First, right click on the `References` node in the solution explorer and click `Add Reference...`
![Adding a project reference](https://apidocs.io/illustration/cs?workspaceFolder=WhatsApp%20Cloud%20API-CSharp&workspaceName=WhatsAppCloudAPI&projectName=WhatsAppCloudAPI.Standard&rootNamespace=WhatsAppCloudAPI.Standard&step=addReference)
Next, a window will be displayed where we must set the `checkbox` on `Tester.Tests` and click `OK`. By doing this, we have added a reference of the `Tester.Tests` project into the new `TestConsoleProject`.
![Creating a project reference](https://apidocs.io/illustration/cs?workspaceFolder=WhatsApp%20Cloud%20API-CSharp&workspaceName=WhatsAppCloudAPI&projectName=WhatsAppCloudAPI.Standard&rootNamespace=WhatsAppCloudAPI.Standard&step=createReference)
### 4. Write sample code
Once the `TestConsoleProject` is created, a file named `Program.cs` will be visible in the solution explorer with an empty `Main` method. This is the entry point for the execution of the entire solution. Here, you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using Controller methods is given in the subsequent sections.
![Adding a project reference](https://apidocs.io/illustration/cs?workspaceFolder=WhatsApp%20Cloud%20API-CSharp&workspaceName=WhatsAppCloudAPI&projectName=WhatsAppCloudAPI.Standard&rootNamespace=WhatsAppCloudAPI.Standard&step=addCode)
## Initialize the API Client
**_Note:_** Documentation for the client can be found [here.](doc/client.md)
The following parameters are configurable for the API Client:
| Parameter | Type | Description |
| --- | --- | --- |
| `Version` | `string` | *Default*: `"v13.0"` |
| `Environment` | Environment | The API environment.
**Default: `Environment.Production`** |
| `Timeout` | `TimeSpan` | Http client timeout.
*Default*: `TimeSpan.FromSeconds(100)` |
| `AccessToken` | `string` | The OAuth 2.0 Access Token to use for API requests. |The API client can be initialized as follows:
```csharp
WhatsAppCloudAPI.Standard.WhatsAppCloudAPIClient client = new WhatsAppCloudAPI.Standard.WhatsAppCloudAPIClient.Builder()
.AccessToken("AccessToken")
.Environment(WhatsAppCloudAPI.Standard.Environment.Production)
.Version("v13.0")
.HttpClientConfig(config => config.NumberOfRetries(0))
.Build();
```## Authorization
This API uses `OAuth 2 Bearer token`.
## List of APIs
* [Business Profiles](doc/controllers/business-profiles.md)
* [Phone Numbers](doc/controllers/phone-numbers.md)
* [Two-Step Verification](doc/controllers/two-step-verification.md)
* [Messages](doc/controllers/messages.md)
* [Registration](doc/controllers/registration.md)
* [Media](doc/controllers/media.md)## Classes Documentation
* [Utility Classes](doc/utility-classes.md)
* [HttpRequest](doc/http-request.md)
* [HttpResponse](doc/http-response.md)
* [HttpStringResponse](doc/http-string-response.md)
* [HttpContext](doc/http-context.md)
* [HttpClientConfiguration](doc/http-client-configuration.md)
* [HttpClientConfiguration Builder](doc/http-client-configuration-builder.md)
* [IAuthManager](doc/i-auth-manager.md)
* [ApiException](doc/api-exception.md)