1. php
由于xdua.com接口访问需要一些敏感信息:key,secret。为了防止泄露这些信息。一般都需要开发者自己部署后台服务来保存key,secret。php就是一个合适的选项。在这种模式下, 开发者开发自己的前端公开api. 然后重映射到xdua.com接口。php版本sdk目前支持版本:php 5.6+
github地址:https://github.com/lovearthhome/lovearth-xdua-php-sdk
获取代码之后用如下方式使用xdua
require_once 'agutil.php';
$resp = (new Agutil())->get("/user/d3d9446802a44259755d38e6d163e820",$headers);
print_r($resp);
地球号api都依赖于dua_id(设置在各个接口的head域),dua_id便是通过本接口获得.
$headers = ["apiv"=>"1.0.0"];
$post_array = [
"dsn"=>"test_dsn",
"app"=>"com.lovearthstudio.testapp",
"apv"=>"1.0.0",
"model"=>"AliYunECS",
"man"=>"AliYun",
"os"=>"CentOS",
"channel"=>"debug"
];
$resp = (new Agutil())->post("/dua",$headers,$post_array);
print_r($resp);
注册用户
$headers = ["dua":"****post:adddua接口获取的dua_id"];
$post_array = [
"by"=>"tel",
"kind"=>"N",
"ustr"=>"+86-15810419001",
"vfcode"=>"FFFFFF",
"pwd"=>"a906449d5769fa7361d7ecc6aa3f6d28",
"ugrp"=>"dua",
"role"=>"None"
];
$resp = (new Agutil())->post("/user",$test_headers,$post_array);
print_r($resp);