CRM扩展
数据接口
- 开发向导
- 单点登录
- 工单
- 客服
- 客户
- 服务记录
- 表单
- 知识库
- 标签
- 账号
请在使用数据接口前,认真阅读本页内容,方便您的后续开发。为了方便您开发过程中定位问题是接口原因,还是您的自身程序问题,建议您自行下载一个Postman。
Restful API是帮我吧新版API,功能更强大、完善。
curl调用格式
curl -u {account}:{password} https://www.bangwo8.com/api/v1/...
curl调用示例
curl -u {osptest}:{xxx} https://www.bangwo8.com/api/v1/tickets.json
数据返回条数太多时,会自动分页,默认每页100条,可以在请求url里更改per_page参数的值来自定义每页返回的条数,建议不要超过100条,因为会影响接口返回速度。 当请求的数据个数超过per_page参数值时,可设置自增的page参数继续请求下一页数据。
示例
{ "tickets": [ ... ], "count": 123, "next_page": "https://www.bangwo8.com/api/v1/tickets.json?page=2", "previous_page": null }
下面以创建工单接口为例进行说明。
c#调用示例
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string url = "http://www.bangwo8.com/api/v1/tickets.json"; HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; //提交方式 request.Method = "POST"; //提交类型 request.ContentType = "application/json"; //提交工单数据 string data = "{\"ticket\": {\"subject\": \"产品咨询\", \"ticketReply\": \ { \"replyMsg\":\"你好,我想咨询下帮我吧产品\" }}}"; byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString()); request.ContentLength = byteData.Length; // 设置Authorization验证 byte[] authBytes = Encoding.UTF8.GetBytes("user:password"); request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(authBytes)); using(Stream postStream = request.GetRequestStream()) { // 写入数据 postStream.Write(byteData, 0, byteData.Length); } try { //正常返回数据 HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); Console.WriteLine(reader.ReadToEnd()); }catch(WebException we){ //捕获异常返回数据 StreamReader reader = new StreamReader(we.Response.GetResponseStream()); Console.WriteLine(reader.ReadToEnd()); } } } }