APIUSB / OpenAPI / 创建打印单

创建打印单

接口描述: 创建打印单

HTTP/HTTPS
请求协议
GET/POST
请求方式
UTF-8
编码格式
JSON
返回格式

接口参数

参数名字类型是否必须默认值其他说明
access_token字符串可选访问令牌,仅当开启签名验证时需要传递,生成令牌可使用App.Auth.ApplyToken接口
param字符串必须-param,例如:{ "from": { "personName": "yule", "countryCode": "US", "phone": "18616038122", "stateCode": "CA", "city": "San Francisco", "addressLine1": "215 Clayton St.", "zipCode": "94117" }, "to": { "personName": "test", "countryCode": "US", "stateCode": "CA", "phone": "18616038122", "city": "Inglewood", "addressLine1": "11222 S La Cienega BLVD", "zipCode": "90304" }, "carrierCode": "fedex", "serviceCode": "fedex_2_day", "isTest": false, "parcels": [ { "packageNum": 1, "length": "5", "width": "5", "height": "5", "distanceUnit": "in", "weight": "4", "massUnit": "lb", "packageCode": "your_package", "extra": { "insurance": 399, "isCod": true, "codAmount": 399, "paymentMethod": "any", "dryIceWeight": 2 } } ], "extra": { "isStd": false, "reference": "gggggggggg", "reference2": "ttttttttttttt" } }

返回字段

返回结果类型说明
ret整型状态码,200表示成功,4xx表示客户端非法请求,5xx表示服务器错误
data对象或混合类型业务数据,由各自接口指定,通常为对象
msg字符串提示信息,失败时的错误提示

在线测试   

参数是否必须
service 必须
access_token 可选
param 必须

客户端请求示例

curl https://api.apiusb.com/api/app?s=App.IntLogistics.CreateLabel&param='{
"from": {
"personName": "yule",
"countryCode": "US",
"phone": "18616038122",
"stateCode": "CA",
"city": "San Francisco",
"addressLine1": "215 Clayton St.",
"zipCode": "94117"
},
"to": {
"personName": "test",
"countryCode": "US",
"stateCode": "CA",
"phone": "18616038122",
"city": "Inglewood",
"addressLine1": "11222 S La Cienega BLVD",
"zipCode": "90304"
},
"carrierCode": "fedex",
"serviceCode": "fedex_2_day",
"isTest": false,
"parcels": [
{
"packageNum": 1,
"length": "5",
"width": "5",
"height": "5",
"distanceUnit": "in",
"weight": "4",
"massUnit": "lb",
"packageCode": "your_package",
"extra": {
"insurance": 399,
"isCod": true,
"codAmount": 399,
"paymentMethod": "any",
"dryIceWeight": 2
}
}
],
"extra": {
"isStd": false,
"reference": "gggggggggg",
"reference2": "ttttttttttttt"
}
}'


{
"ret": 200,
"data": {
"result": "OK",
"message": "",
"data": {
"objectId": "f03b5014e17d11e7aed3035406551f52",
"status": 1,
"trackingNumber": [
"788948913744"
],
"trackingUrl": [
"https://www.fedex.com/apps/fedextrack/?action=track&cntry_code=us&trackingnumber=788948913744"
],
"pdfUrl": "http://127.0.0.1:2224/label/printLabel?objectId=f03b5014e17d11e7aed3035406551f52",
"labelUrl": [
"http://127.0.0.1:2223/shipment/printLabel?objectId=f03b5014e17d11e7aed3035406551f52"
],
"invoiceUrl": [
null
],
"rate": 36.36,
"createTime": "2017-12-15 09:54:28",
"billedAmonut": 0,
"feeDetail": {
"DryIce": 5,
"Cod": 13,
"Insurance": 4,
"Fuel": 0.55,
"baseRate": 13.81
}
}
},
"msg": "",
}

curl https://api.apiusb.com/api/app?s=App.IntLogistics.CreateLabel&param='{
                           "from": {
                           "personName": "yule",
                           "countryCode": "US",
                           "phone": "18616038122",
                           "stateCode": "CA",
                           "city": "San Francisco",
                           "addressLine1": "215 Clayton St.",
                           "zipCode": "94117"
                           },
                           "to": {
                           "personName": "test",
                           "countryCode": "US",
                           "stateCode": "CA",
                           "phone": "18616038122",
                           "city": "Inglewood",
                           "addressLine1": "11222 S La Cienega BLVD",
                           "zipCode": "90304"
                           },
                           "carrierCode": "fedex",
                           "serviceCode": "fedex_2_day",
                           "isTest": false,
                           "parcels": [
                           {
                           "packageNum": 1,
                           "length": "5",
                           "width": "5",
                           "height": "5",
                           "distanceUnit": "in",
                           "weight": "4",
                           "massUnit": "lb",
                           "packageCode": "your_package",
                           "extra": {
                           "insurance": 399,
                           "isCod": true,
                           "codAmount": 399,
                           "paymentMethod": "any",
                           "dryIceWeight": 2
                           }
                           }
                           ],
                           "extra": {
                           "isStd": false,
                           "reference": "gggggggggg",
                           "reference2": "ttttttttttttt"
                           }
                           }'

{
"ret": 200,
"data": {
"result": "OK",
"message": "",
"data": {
"objectId": "f03b5014e17d11e7aed3035406551f52",
"status": 1,
"trackingNumber": [
"788948913744"
],
"trackingUrl": [
"https://www.fedex.com/apps/fedextrack/?action=track&cntry_code=us&trackingnumber=788948913744"
],
"pdfUrl": "http://127.0.0.1:2224/label/printLabel?objectId=f03b5014e17d11e7aed3035406551f52",
"labelUrl": [
"http://127.0.0.1:2223/shipment/printLabel?objectId=f03b5014e17d11e7aed3035406551f52"
],
"invoiceUrl": [
null
],
"rate": 36.36,
"createTime": "2017-12-15 09:54:28",
"billedAmonut": 0,
"feeDetail": {
"DryIce": 5,
"Cod": 13,
"Insurance": 4,
"Fuel": 0.55,
"baseRate": 13.81
}
}
},
"msg": "",
}





var param = '{"from": {"personName": "yule","countryCode": "US","phone": "18616038122","stateCode": "CA","city": "San Francisco","addressLine1": "215 Clayton St.","zipCode": "94117"},"to": {"personName": "test","countryCode": "US","stateCode": "CA","phone": "18616038122","city": "Inglewood","addressLine1": "11222 S La Cienega BLVD","zipCode": "90304"},"carrierCode": "fedex","serviceCode": "fedex_2_day","isTest": false,"parcels": [{"packageNum": 1,"length": "5","width": "5","height": "5","distanceUnit": "in","weight": "4","massUnit": "lb","packageCode": "your_package","extra": { "insurance": 399,"isCod": true,"codAmount": 399,"paymentMethod": "any","dryIceWeight": 2 }}],"extra": {"isStd": false,"reference": "gggggggggg","reference2": "ttttttttttttt"}}';
$.ajax({
    url: "https://api.apiusb.com/api/app",
    data: {s: "App.IntLogistics.CreateLabel", param: param},
    dataType: 'json',
    success: function (response, status, xhr) {
        console.log(response);
    }
});



<?php
require_once dirname(__FILE__) . '/PhalApiClient.php';

$client = PhalApiClient::create()
    ->withHost('https://api.apiusb.com/api/app');$rs = $client->reset()
->withService('App.IntLogistics.CreateLabel')
->withParams('param', '{
                            "from": {
                            "personName": "yule",
                            "countryCode": "US",
                            "phone": "18616038122",
                            "stateCode": "CA",
                            "city": "San Francisco",
                            "addressLine1": "215 Clayton St.",
                            "zipCode": "94117"
                            },
                            "to": {
                            "personName": "test",
                            "countryCode": "US",
                            "stateCode": "CA",
                            "phone": "18616038122",
                            "city": "Inglewood",
                            "addressLine1": "11222 S La Cienega BLVD",
                            "zipCode": "90304"
                            },
                            "carrierCode": "fedex",
                            "serviceCode": "fedex_2_day",
                            "isTest": false,
                            "parcels": [
                            {
                            "packageNum": 1,
                            "length": "5",
                            "width": "5",
                            "height": "5",
                            "distanceUnit": "in",
                            "weight": "4",
                            "massUnit": "lb",
                            "packageCode": "your_package",
                            "extra": {
                            "insurance": 399,
                            "isCod": true,
                            "codAmount": 399,
                            "paymentMethod": "any",
                            "dryIceWeight": 2
                            }
                            }
                            ],
                            "extra": {
                            "isStd": false,
                            "reference": "gggggggggg",
                            "reference2": "ttttttttttttt"
                            }
                            }')
->withTimeout(3000)
->request();







// ret状态码,200表示成功
var_dump($rs->getRet());
// 业务数据
var_dump($rs->getData());
// 提示信息
var_dump($rs->getMsg());
#-*- coding:utf-8 -*-
import PhalApiClient

result = PhalApiClient.PhalApiClient('https://api.apiusb.com/api/app', 'App.IntLogistics.CreateLabelx', {'param': '{
                                                                 "from": {
                                                                 "personName": "yule",
                                                                 "countryCode": "US",
                                                                 "phone": "18616038122",
                                                                 "stateCode": "CA",
                                                                 "city": "San Francisco",
                                                                 "addressLine1": "215 Clayton St.",
                                                                 "zipCode": "94117"
                                                                 },
                                                                 "to": {
                                                                 "personName": "test",
                                                                 "countryCode": "US",
                                                                 "stateCode": "CA",
                                                                 "phone": "18616038122",
                                                                 "city": "Inglewood",
                                                                 "addressLine1": "11222 S La Cienega BLVD",
                                                                 "zipCode": "90304"
                                                                 },
                                                                 "carrierCode": "fedex",
                                                                 "serviceCode": "fedex_2_day",
                                                                 "isTest": false,
                                                                 "parcels": [
                                                                 {
                                                                 "packageNum": 1,
                                                                 "length": "5",
                                                                 "width": "5",
                                                                 "height": "5",
                                                                 "distanceUnit": "in",
                                                                 "weight": "4",
                                                                 "massUnit": "lb",
                                                                 "packageCode": "your_package",
                                                                 "extra": {
                                                                 "insurance": 399,
                                                                 "isCod": true,
                                                                 "codAmount": 399,
                                                                 "paymentMethod": "any",
                                                                 "dryIceWeight": 2
                                                                 }
                                                                 }
                                                                 ],
                                                                 "extra": {
                                                                 "isStd": false,
                                                                 "reference": "gggggggggg",
                                                                 "reference2": "ttttttttttttt"
                                                                 }
                                                                 }'}, 3)








//FullscreenActivity.java
import net.phalapi.sdk.*;    /**
     * 网络操作相关的子线程
     */
    Runnable networkTask = new Runnable() {

        @Override
        public void run() {
            // TODO
            // 在这里进行 http request.网络请求相关操作

        	PhalApiClient client = PhalApiClient.create()
	       			    .withHost("https://api.apiusb.com/api/app");

	       	PhalApiClientResponse response = client
	       			    .withService("App.IntLogistics.CreateLabel")
	       			    .withParams("param", "{
                                                 "from": {
                                                 "personName": "yule",
                                                 "countryCode": "US",
                                                 "phone": "18616038122",
                                                 "stateCode": "CA",
                                                 "city": "San Francisco",
                                                 "addressLine1": "215 Clayton St.",
                                                 "zipCode": "94117"
                                                 },
                                                 "to": {
                                                 "personName": "test",
                                                 "countryCode": "US",
                                                 "stateCode": "CA",
                                                 "phone": "18616038122",
                                                 "city": "Inglewood",
                                                 "addressLine1": "11222 S La Cienega BLVD",
                                                 "zipCode": "90304"
                                                 },
                                                 "carrierCode": "fedex",
                                                 "serviceCode": "fedex_2_day",
                                                 "isTest": false,
                                                 "parcels": [
                                                 {
                                                 "packageNum": 1,
                                                 "length": "5",
                                                 "width": "5",
                                                 "height": "5",
                                                 "distanceUnit": "in",
                                                 "weight": "4",
                                                 "massUnit": "lb",
                                                 "packageCode": "your_package",
                                                 "extra": {
                                                 "insurance": 399,
                                                 "isCod": true,
                                                 "codAmount": 399,
                                                 "paymentMethod": "any",
                                                 "dryIceWeight": 2
                                                 }
                                                 }
                                                 ],
                                                 "extra": {
                                                 "isStd": false,
                                                 "reference": "gggggggggg",
                                                 "reference2": "ttttttttttttt"
                                                 }
                                                 }")
	       			    .withTimeout(3000)
	       			    .request();

	   		String content = "";
	   		content += "ret=" + response.getRet() + "\n";
	   		if (response.getRet() == 200) {
				try {
					JSONObject data = new JSONObject(response.getData());
					content += "data.title=" + data.getString("title") + "\n";
					content += "data.content=" + data.getString("content") + "\n";
					content += "data.version=" + data.getString("version") + "\n";
				} catch (JSONException ex) {

				}
	   		}
			content += "msg=" + response.getMsg() + "\n";

			Log.v("[PhalApiClientResponse]", content);


            Message msg = new Message();
            Bundle data = new Bundle();
            data.putString("value", content);
            msg.setData(data);
            handler.sendMessage(msg);
        }
    };



PhalApiClientResponse response = PhalApiClient.create()
  .withHost("https://api.apiusb.com/api/app")
  .withService("App.IntLogistics.CreateLabel")
  .withparamsList("param", '{
                                "from": {
                                "personName": "yule",
                                "countryCode": "US",
                                "phone": "18616038122",
                                "stateCode": "CA",
                                "city": "San Francisco",
                                "addressLine1": "215 Clayton St.",
                                "zipCode": "94117"
                                },
                                "to": {
                                "personName": "test",
                                "countryCode": "US",
                                "stateCode": "CA",
                                "phone": "18616038122",
                                "city": "Inglewood",
                                "addressLine1": "11222 S La Cienega BLVD",
                                "zipCode": "90304"
                                },
                                "carrierCode": "fedex",
                                "serviceCode": "fedex_2_day",
                                "isTest": false,
                                "parcels": [
                                {
                                "packageNum": 1,
                                "length": "5",
                                "width": "5",
                                "height": "5",
                                "distanceUnit": "in",
                                "weight": "4",
                                "massUnit": "lb",
                                "packageCode": "your_package",
                                "extra": {
                                "insurance": 399,
                                "isCod": true,
                                "codAmount": 399,
                                "paymentMethod": "any",
                                "dryIceWeight": 2
                                }
                                }
                                ],
                                "extra": {
                                "isStd": false,
                                "reference": "gggggggggg",
                                "reference2": "ttttttttttttt"
                                }
                                }')
  .withTimeout(3000)
  .request();

Log.v("response ret", response.ret + "");
Log.v("response data", response.data);
Log.v("response msg", response.msg);

#import "AFNPhalApiClient.h"// POST
NSDictionary *params = @{@"param": @"{
                                        "from": {
                                        "personName": "yule",
                                        "countryCode": "US",
                                        "phone": "18616038122",
                                        "stateCode": "CA",
                                        "city": "San Francisco",
                                        "addressLine1": "215 Clayton St.",
                                        "zipCode": "94117"
                                        },
                                        "to": {
                                        "personName": "test",
                                        "countryCode": "US",
                                        "stateCode": "CA",
                                        "phone": "18616038122",
                                        "city": "Inglewood",
                                        "addressLine1": "11222 S La Cienega BLVD",
                                        "zipCode": "90304"
                                        },
                                        "carrierCode": "fedex",
                                        "serviceCode": "fedex_2_day",
                                        "isTest": false,
                                        "parcels": [
                                        {
                                        "packageNum": 1,
                                        "length": "5",
                                        "width": "5",
                                        "height": "5",
                                        "distanceUnit": "in",
                                        "weight": "4",
                                        "massUnit": "lb",
                                        "packageCode": "your_package",
                                        "extra": {
                                        "insurance": 399,
                                        "isCod": true,
                                        "codAmount": 399,
                                        "paymentMethod": "any",
                                        "dryIceWeight": 2
                                        }
                                        }
                                        ],
                                        "extra": {
                                        "isStd": false,
                                        "reference": "gggggggggg",
                                        "reference2": "ttttttttttttt"
                                        }
                                        }"};

// Call AFNPhalApiClient
[[[[[AFNPhalApiClient sharedClient] withHost:@"https://api.apiusb.com/api/app"] withService:@"App.IntLogistics.CreateLabel"] withParams:params] requestWithFormDataBlock:^(id formData) {
	//
    [formData appendPartWithFileData:UIImageJPEGRepresentation([UIImage imageNamed:@"head.JPG"], 1) name:@"file" fileName:@"image.jpg" mimeType:@"image/jpeg"];
} completeBlock:^(id resultObject) {
    PALog(@"resultObject: %@", resultObject);
} failureBlock:^(NSError *error) {
    PALog(@"error: %@", error);
}];

// Print url
PALog(@"total url: %@", [[AFNPhalApiClient sharedClient] printTotalUrlStr]);





错误列表

错误状态码错误描述信息
400表示客户端参数错误
404表示接口服务不存在
500表示服务端内部错误

本文档生成时间:2024-05-02 06:04:41