API地址:http://api.gfax.cn/querytask/{msgid}/{format}
msgid为发送传真时的msgid参数,如果用户没有自己指定,则发送之后系统会返回一个自动生成的msgid
format 为服务器返回结果的格式,可以为xml,json
status代码 | description描述 |
---|---|
-1 | 初始化失败 |
-2 | 没有找到任务 |
-3 | 认证失败 |
0 | 接受任务 |
1 | 正在初始化 |
3 | 等待发送 |
4 | 正在发送 |
5 | 任务暂停 |
9 | 任务完成 |
static String format = "xml"; static String userid = "demo@gfax.cn"; static String pass = "mypassword"; static String deskey = "mydeskey"; //查询传真任务 public static void queryTask() { AllcomUtil allcom = new AllcomUtil(userid,pass,AllcomUtil.MD5); String msgid = "interface-jun@gfax.cn-367477402687"; String url = "http://api.gfax.cn:8088/querytask/" + msgid + "/" + format; while (true) { String result = allcom.getHttp(url); if (result == null) { break; } else { System.out.println(result); // 通过xml解析器判断是否完成 boolean done = false; if (!done) { try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } } } } }
require("allcomutil.php"); $userid = "jun@gfax.cn"; $pass = "mxjunolkd"; $allcom = new allcom($userid,$pass); $format = "xml"; $msgid = "interface-jun@gfax.cn-1367477402687"; $url = "http://api.gfax.cn:8088/querytask/".$msgid."/".$format; $result = $allcom->getHttp($url){ echo $result;
string userid = "jun@gfax.cn"; string pass = "mxjunolkd"; string deskey = "ttttaaaa"; AllcomUtil allcom = new AllcomUtil(userid,pass,2,deskey); string msgid = "interface-jun@gfax.cn-1367477402687"; string result = allcom.getHttp("http://api.gfax.cn:8088/querytask/"+msgid+"/xml"); Console.WriteLine(result);
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <gfaxroot> <status>9</status> <description>任务完成</description> <faxitem> <cost>28</cost> <custid>511722990001</custid> <description>成功</description> <faxno>51010001</faxno> <fee>0.15</fee> <messageid>interface-demo@gfax.cn-1329037244400</messageid> <status>0</status> <taskid>201305200006000000</taskid> </faxitem> <faxitem> <cost>28</cost> <custid>511722990001</custid> <description>成功</description> <faxno>51010002</faxno> <fee>0.15</fee> <messageid>interface-demo@gfax.cn-1329037244400</messageid> <status>0</status> <taskid>201305200006000000</taskid> </faxitem> </gfaxroot>服务器返回示例2
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <gfaxroot> <status>4</status> <description>正在发送</description> </gfaxroot>服务器返回示例3
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <gfaxroot> <status>-3</status> <description>身份认证失败</description> </gfaxroot>