The SDK allows you to receive and send messages through your messengers account. Sign up now
Download SDK and unpack the archive. Connect SDK to your project.
Building the API client library requires Maven to be installed.
To install the API client library to your local Maven repository, simply execute:
mvn install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn deploy
Refer to the official documentation for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-android-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project's build file:
compile "org.openapitools:openapi-android-client:1.0.0"
At first generate the JAR by executing:
mvn package
Then manually install the following JARs:
Please follow the installation instruction and execute the following Java code:
import org.openapitools.client.api.Class1InstanceApi;
public class Class1InstanceApiExample {
public static void main(String[] args) {
Class1InstanceApi apiInstance = new Class1InstanceApi();
try {
InlineResponse2002 result = apiInstance.expiry();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling Class1InstanceApi#expiry");
e.printStackTrace();
}
}
}
All URIs are relative to https://api.chat-api.com
Authentication schemes defined for the API:
Type: API key
API key parameter name: instanceId
Location: URL query string
Type: API key
API key parameter name: token
Location: URL query string
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.
At the very beginning, we need to connect messengers with our script, so as we write the code, we check its operation. To do this, go to your personal account and get a QR code there. Next, open messengers on your smartphone, go to Settings -> messengers Web -> Scan a QR code.
Now we need to indicate a WebHook URL so the server can run the scrip when new messages arrive. Indicate a direct link to your script. You can’t indicate server IP only, but you can indicate the port.
The generated code uses a few Gradle dependencies e.g., Jackson, Volley, and Apache HttpClient. The reference to these dependencies is already added in the build.gradle file will be installed automatically. Therefore, you will need internet access for a successful build.
Open an Existing Android Project
.Ok
.Build > Make Project
or pressing Ctrl + F9
.The following section explains how to use the messengersAPI library in a new project.
For starting a new project, click on Create New Android Studio Project
.
Here, configure the new project by adding the name, domain and location of the sample application followed by clicking Next
.
Following this, select the Phone and Tablet
option as shown in the illustration below and click Next
.
In the following step, choose Empty Activity
as the activity type and click Next
.
In this step, provide an Activity Name
and Layout Name
and click Finish
. This would take you to the newly created project.
In order to add a dependency to this sample application, click on the android button shown in the project explorer on the left side as shown in the picture. Click on Project
in the drop down that emerges.
Right click the sample application in the project explorer and click on New > Module
as shown in the picture.
Choose Import Gradle Project
and click Next
.
Click on Finish
which would take you back to the sample application with the refernced SDK.
In the following step first navigate to the SampleApplication > settings.gradle
file and add the line
Then navigate to the ``` SampleApplication > app > build.gradle ``` file and add the following line
implementation project(path: ':messengersAPILib')``` to the dependencies section as shown in the illustration below. Also add the following packagingOptions.
packagingOptions exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/DEPENDENCIES' }
Finally, press Sync Now
in the warning visible as shown in the picture below.
Once the SampleApplication
is created, a file named SampleApplication > app > src > main > java > MainActivity
will be visible in the Project Explorer with an onCreate
method. This is the entry point for the execution of the created project.
Here, you can add code to initialize the client library and instantiate a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.
The generated code and the server can be tested using automatically generated test cases. JUnit is used as the testing framework and test runner.
In Android Studio, for running the tests do the following: