APP 接入方式

优质
小牛编辑
124浏览
2023-12-01

APP接入方式

在APP中添加爱客服咨询链接

我们为需要在APP中集成爱客服的用户提供两种接入方式,第一种是在企业自己开发的APP中添加爱客服移动咨询链接,企业可以在自己开发的APP中添加咨询按钮或者咨询入口,直接链接到客服咨询页面。

APP中咨询链接的获取方式与移动网站独立页面链接获取方式一致。进入爱客服后台,点击【接入管理】,进入【移动网站客服】,点击复制前台页面地址,将前台页面地址放至您需要链接的APP入口即可。

APP咨询链接获取页面:

使用APP原生接入爱客服

我们为企业提供APP调用地址和集成方法,调用说明如下:

调 用 方 式: Httpclient 接入

http请求方式: POST

请 求 地 址: 按照以下步骤复制APP接口url

请求地址需要登录爱客服后台进行获取,进入爱客服后台,点击【接入管理】,点击【接入APP】,复制APP接口url。

APP咨询链接获取页面:

请求参数示例:

请求参数解释:

返回参数示例:

返回参数解释:

返回码errcode、问题类型questionType返回值解释:

3.爱客服APP接入的DEMO示例

您可以让您的技术和开发人员参考DEMO示例。

需要的jar包:

httpclient-4.3.3jar、httpclient-cache-4.3.3jar、httpcore-4.3.2jar、httpmime-4.3.3jar

Java程序:

package com.web.dao;

import java.io.IOException;

importjava.io.UnsupportedEncodingException;

import java.util.ArrayList;

import java.util.List;

importorg.apache.http.HttpEntity;

importorg.apache.http.NameValuePair;

importorg.apache.http.client.ClientProtocolException;

importorg.apache.http.client.entity.UrlEncodedFormEntity;

importorg.apache.http.client.methods.CloseableHttpResponse;

importorg.apache.http.client.methods.HttpPost;

importorg.apache.http.impl.client.CloseableHttpClient;

importorg.apache.http.impl.client.HttpClients;

import org.apache.http.message.BasicNameValuePair;

importorg.apache.http.util.EntityUtils;

public class Demo {

public static HttpPost getHttppost(String url,String fromuser,String reqtype,String ip,String q){

HttpPost httppost = null;

try {

httppost = new HttpPost(url);

// 创建参数队列

List<NameValuePair>formparams = new ArrayList<NameValuePair>();

formparams.add(new BasicNameValuePair("fromuser", fromuser));

formparams.add(new BasicNameValuePair("reqtype", reqtype));

formparams.add(new BasicNameValuePair("ip", ip));

formparams.add(new BasicNameValuePair("q", q));

//打包将要传入的参数

UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8");

httppost.setEntity(uefEntity);

} catch (UnsupportedEncodingException e) {

e.printStackTrace();

}

return httppost;

}

public static void main(String[] args){

CloseableHttpClient httpclient = HttpClients.createDefault();

// 创建httppost

HttpPost httppost = getHttppost("[复制的域名]","[用户ID]","[请求类型]","[用户IP]","[问题内容]");

//提交请求数据

CloseableHttpResponse response = null;

try {

response = httpclient.execute(httppost);

HttpEntity entity = response.getEntity();

//请求成功

if (entity != null) {

System.out.println("Response content: " + EntityUtils.toString(entity, "UTF-8"));

}else{

//请求失败代码

}

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}finally {

try {

if(response!=null){

response.close();

}

httpclient.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}