用户 - 外部账号
版本:v1
认证方式:Bearer Token
目录
接口列表
绑定外部账号
接口说明
绑定外部账号,如果已存在绑定则直接返回成功
基本信息
- 接口名称:绑定外部账号
- 请求方式:POST
- 请求路径:/ExternalAccount/{appKey}
请求参数
Path 参数
参数名 |
示例值 |
参数描述 |
是否必填 |
appKey |
- |
- |
是 |
Body 参数
参数名 |
类型 |
示例值 |
参数描述 |
是否必填 |
unionID |
string |
- |
- |
是 |
platform |
string |
- |
- |
是 |
platformName |
string |
- |
- |
是 |
avatar |
string |
- |
- |
否 |
data |
string |
- |
- |
否 |
示例代码
| import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
public class ApiClient {
public static void main(String[] args) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create("{server}/ExternalAccount/{appKey}"))
.header("Authorization", "Bearer {your_access_token}")
.header("Content-Type", "application/json");
// 创建请求体数据
Map<String, Object> data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
};
ObjectMapper mapper = new ObjectMapper();
String jsonBody = mapper.writeValueAsString(data);
RequestBody body = RequestBody.create(
MediaType.parse("application/json"), jsonBody);
requestBuilder.method("post", HttpRequest.BodyPublishers.ofString(jsonBody));
try {
HttpResponse<String> response = client.send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import requests
url = "{server}/ExternalAccount/{appKey}"
headers = {
"Authorization": "Bearer {your_access_token}",
"Content-Type": "application/json"
}
data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
}
response = requests.post(
url,
headers=headers,
json=data
)
print(response.json())
|
| package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main() {
client := &http.Client{}
var req *http.Request
var err error
data := {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
}
jsonBody, err := json.Marshal(data)
if err != nil {
panic(err)
}
req, err = http.NewRequest("post", "{server}/ExternalAccount/{appKey}", bytes.NewBuffer(jsonBody))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer {your_access_token}")
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
|
| const axios = require('axios');
const data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
};
const config = {
method: 'post',
url: '{server}/ExternalAccount/{appKey}',
headers: {
'Authorization': 'Bearer {your_access_token}',
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
|
| <?php
$url = "{server}/ExternalAccount/{appKey}";
$headers = [
"Authorization: Bearer {your_access_token}",
"Content-Type: application/json"
];
$data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
};
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "post");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
|
| using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text;
using System.Text.Json;
class Program
{
static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer {your_access_token}");
HttpResponseMessage response;
var data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
};
var content = new StringContent(
JsonSerializer.Serialize(data),
Encoding.UTF8,
"application/json");
response = await client.postAsync("{server}/ExternalAccount/{appKey}", content);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}
|
| require 'net/http'
require 'json'
uri = URI("{server}/ExternalAccount/{appKey}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::undefined.new(uri)
request["Authorization"] = "Bearer {your_access_token}"
request["Content-Type"] = "application/json"
data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
}
request.set_form_data(data)
response = http.request(request)
puts response.body
|
| const data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
};
fetch("{server}/ExternalAccount/{appKey}", {
method: "post",
headers: {
"Authorization": "Bearer {your_access_token}",
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.catch(error => console.error(error));
|
| import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.json.JSONObject;
public class ApiClient {
private final OkHttpClient client = new OkHttpClient();
public void makeRequest() {
Request.Builder requestBuilder = new Request.Builder()
.url("{server}/ExternalAccount/{appKey}")
.addHeader("Authorization", "Bearer {your_access_token}")
.addHeader("Content-Type", "application/json");
JSONObject data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
};
RequestBody body = RequestBody.create(
MediaType.parse("application/json"), data.toString());
requestBuilder.method("post", body);
try (Response response = client.newCall(requestBuilder.build()).execute()) {
System.out.println(response.body().string());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import Foundation
let url = URL(string: "{server}/ExternalAccount/{appKey}")!
var request = URLRequest(url: url)
request.httpMethod = "post"
request.setValue("Bearer {your_access_token}", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let data = {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
}
let jsonData = try? JSONSerialization.data(withJSONObject: data)
request.httpBody = jsonData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
if let json = try? JSONSerialization.jsonObject(with: data) {
print(json)
}
}
}
task.resume()
|
返回结果
| {
"code": 200 // 状态码,
"data": false // 响应数据,
"error": "" // 错误信息
}
|
字段名 |
类型 |
描述 |
是否必填 |
code |
integer |
状态码 |
否 |
data |
boolean |
响应数据 |
否 |
error |
string |
错误信息 |
否 |
外部账号列表
基本信息
- 接口名称:外部账号列表
- 请求方式:GET
- 请求路径:/ExternalAccount/{appKey}
请求参数
Path 参数
参数名 |
示例值 |
参数描述 |
是否必填 |
appKey |
- |
- |
是 |
示例代码
| import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
public class ApiClient {
public static void main(String[] args) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create("{server}/ExternalAccount/{appKey}"))
.header("Authorization", "Bearer {your_access_token}");
requestBuilder.method("get", HttpRequest.BodyPublishers.noBody());
try {
HttpResponse<String> response = client.send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import requests
url = "{server}/ExternalAccount/{appKey}"
headers = {
"Authorization": "Bearer {your_access_token}"
}
response = requests.get(
url,
headers=headers
)
print(response.json())
|
| package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main() {
client := &http.Client{}
var req *http.Request
var err error
req, err = http.NewRequest("get", "{server}/ExternalAccount/{appKey}", nil)
if err != nil {
panic(err)
}
req.Header.Add("Authorization", "Bearer {your_access_token}")
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
|
| const axios = require('axios');
const config = {
method: 'get',
url: '{server}/ExternalAccount/{appKey}',
headers: {
'Authorization': 'Bearer {your_access_token}'
}
};
axios(config)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
|
| <?php
$url = "{server}/ExternalAccount/{appKey}";
$headers = [
"Authorization: Bearer {your_access_token}"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "get");
$response = curl_exec($ch);
curl_close($ch);
echo $response;
|
| using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text;
using System.Text.Json;
class Program
{
static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer {your_access_token}");
HttpResponseMessage response;
response = await client.getAsync("{server}/ExternalAccount/{appKey}");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}
|
| require 'net/http'
require 'json'
uri = URI("{server}/ExternalAccount/{appKey}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::undefined.new(uri)
request["Authorization"] = "Bearer {your_access_token}"
response = http.request(request)
puts response.body
|
| fetch("{server}/ExternalAccount/{appKey}", {
method: "get",
headers: {
"Authorization": "Bearer {your_access_token}"
}
})
.then(response => response.json())
.catch(error => console.error(error));
|
| import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.json.JSONObject;
public class ApiClient {
private final OkHttpClient client = new OkHttpClient();
public void makeRequest() {
Request.Builder requestBuilder = new Request.Builder()
.url("{server}/ExternalAccount/{appKey}")
.addHeader("Authorization", "Bearer {your_access_token}");
requestBuilder.method("get", null);
try (Response response = client.newCall(requestBuilder.build()).execute()) {
System.out.println(response.body().string());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import Foundation
let url = URL(string: "{server}/ExternalAccount/{appKey}")!
var request = URLRequest(url: url)
request.httpMethod = "get"
request.setValue("Bearer {your_access_token}", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
if let json = try? JSONSerialization.jsonObject(with: data) {
print(json)
}
}
}
task.resume()
|
返回结果
| {
"code": 200 // 状态码,
"data": [
{
"id": "0" // 唯一标识符,
"userID": "0" // 关联的用户ID,
"platformName": "" // 第三方平台名称,
"platform": "" // 第三方平台,
"unionID": "" // 第三方平台唯一标识,
"avatar": "" // 用户头像,
"data": "" // 扩展数据,
"enable": false // 启用,
"createDate": "" // 创建时间,
"lastUpdate": "" // 最后更新时间
}
] // 响应数据,
"error": "" // 错误信息
}
|
字段名 |
类型 |
描述 |
是否必填 |
code |
integer |
状态码 |
否 |
data |
array<UserLogins> |
响应数据 |
否 |
error |
string |
错误信息 |
否 |
删除绑定账号
基本信息
- 接口名称:删除绑定账号
- 请求方式:DELETE
- 请求路径:/ExternalAccount/{appKey}/{id}
请求参数
Path 参数
参数名 |
示例值 |
参数描述 |
是否必填 |
id |
- |
绑定ID |
是 |
appKey |
- |
- |
是 |
示例代码
| import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
public class ApiClient {
public static void main(String[] args) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create("{server}/ExternalAccount/{appKey}/{id}"))
.header("Authorization", "Bearer {your_access_token}");
requestBuilder.method("delete", HttpRequest.BodyPublishers.noBody());
try {
HttpResponse<String> response = client.send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import requests
url = "{server}/ExternalAccount/{appKey}/{id}"
headers = {
"Authorization": "Bearer {your_access_token}"
}
response = requests.delete(
url,
headers=headers
)
print(response.json())
|
| package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main() {
client := &http.Client{}
var req *http.Request
var err error
req, err = http.NewRequest("delete", "{server}/ExternalAccount/{appKey}/{id}", nil)
if err != nil {
panic(err)
}
req.Header.Add("Authorization", "Bearer {your_access_token}")
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
|
| const axios = require('axios');
const config = {
method: 'delete',
url: '{server}/ExternalAccount/{appKey}/{id}',
headers: {
'Authorization': 'Bearer {your_access_token}'
}
};
axios(config)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
|
| <?php
$url = "{server}/ExternalAccount/{appKey}/{id}";
$headers = [
"Authorization: Bearer {your_access_token}"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "delete");
$response = curl_exec($ch);
curl_close($ch);
echo $response;
|
| using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text;
using System.Text.Json;
class Program
{
static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer {your_access_token}");
HttpResponseMessage response;
response = await client.deleteAsync("{server}/ExternalAccount/{appKey}/{id}");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}
|
| require 'net/http'
require 'json'
uri = URI("{server}/ExternalAccount/{appKey}/{id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::undefined.new(uri)
request["Authorization"] = "Bearer {your_access_token}"
response = http.request(request)
puts response.body
|
| fetch("{server}/ExternalAccount/{appKey}/{id}", {
method: "delete",
headers: {
"Authorization": "Bearer {your_access_token}"
}
})
.then(response => response.json())
.catch(error => console.error(error));
|
| import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.json.JSONObject;
public class ApiClient {
private final OkHttpClient client = new OkHttpClient();
public void makeRequest() {
Request.Builder requestBuilder = new Request.Builder()
.url("{server}/ExternalAccount/{appKey}/{id}")
.addHeader("Authorization", "Bearer {your_access_token}");
requestBuilder.method("delete", null);
try (Response response = client.newCall(requestBuilder.build()).execute()) {
System.out.println(response.body().string());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import Foundation
let url = URL(string: "{server}/ExternalAccount/{appKey}/{id}")!
var request = URLRequest(url: url)
request.httpMethod = "delete"
request.setValue("Bearer {your_access_token}", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
if let json = try? JSONSerialization.jsonObject(with: data) {
print(json)
}
}
}
task.resume()
|
返回结果
| {
"code": 200 // 状态码,
"data": false // 响应数据,
"error": "" // 错误信息
}
|
字段名 |
类型 |
描述 |
是否必填 |
code |
integer |
状态码 |
否 |
data |
boolean |
响应数据 |
否 |
error |
string |
错误信息 |
否 |
更新绑定账号
基本信息
- 接口名称:更新绑定账号
- 请求方式:PUT
- 请求路径:/ExternalAccount/{appKey}/{id}
请求参数
Path 参数
参数名 |
示例值 |
参数描述 |
是否必填 |
id |
- |
绑定ID |
是 |
appKey |
- |
- |
是 |
Body 参数
参数名 |
类型 |
示例值 |
参数描述 |
是否必填 |
avatar |
string |
- |
头像 |
否 |
data |
string |
- |
自定义数据 |
否 |
enable |
boolean |
- |
启用 |
否 |
示例代码
| import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
public class ApiClient {
public static void main(String[] args) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create("{server}/ExternalAccount/{appKey}/{id}"))
.header("Authorization", "Bearer {your_access_token}")
.header("Content-Type", "application/json");
// 创建请求体数据
Map<String, Object> data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
};
ObjectMapper mapper = new ObjectMapper();
String jsonBody = mapper.writeValueAsString(data);
RequestBody body = RequestBody.create(
MediaType.parse("application/json"), jsonBody);
requestBuilder.method("put", HttpRequest.BodyPublishers.ofString(jsonBody));
try {
HttpResponse<String> response = client.send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import requests
url = "{server}/ExternalAccount/{appKey}/{id}"
headers = {
"Authorization": "Bearer {your_access_token}",
"Content-Type": "application/json"
}
data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
}
response = requests.put(
url,
headers=headers,
json=data
)
print(response.json())
|
| package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main() {
client := &http.Client{}
var req *http.Request
var err error
data := {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
}
jsonBody, err := json.Marshal(data)
if err != nil {
panic(err)
}
req, err = http.NewRequest("put", "{server}/ExternalAccount/{appKey}/{id}", bytes.NewBuffer(jsonBody))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer {your_access_token}")
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
|
| const axios = require('axios');
const data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
};
const config = {
method: 'put',
url: '{server}/ExternalAccount/{appKey}/{id}',
headers: {
'Authorization': 'Bearer {your_access_token}',
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
|
| <?php
$url = "{server}/ExternalAccount/{appKey}/{id}";
$headers = [
"Authorization: Bearer {your_access_token}",
"Content-Type: application/json"
];
$data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
};
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "put");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
|
| using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text;
using System.Text.Json;
class Program
{
static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer {your_access_token}");
HttpResponseMessage response;
var data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
};
var content = new StringContent(
JsonSerializer.Serialize(data),
Encoding.UTF8,
"application/json");
response = await client.putAsync("{server}/ExternalAccount/{appKey}/{id}", content);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}
|
| require 'net/http'
require 'json'
uri = URI("{server}/ExternalAccount/{appKey}/{id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::undefined.new(uri)
request["Authorization"] = "Bearer {your_access_token}"
request["Content-Type"] = "application/json"
data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
}
request.set_form_data(data)
response = http.request(request)
puts response.body
|
| const data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
};
fetch("{server}/ExternalAccount/{appKey}/{id}", {
method: "put",
headers: {
"Authorization": "Bearer {your_access_token}",
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.catch(error => console.error(error));
|
| import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.json.JSONObject;
public class ApiClient {
private final OkHttpClient client = new OkHttpClient();
public void makeRequest() {
Request.Builder requestBuilder = new Request.Builder()
.url("{server}/ExternalAccount/{appKey}/{id}")
.addHeader("Authorization", "Bearer {your_access_token}")
.addHeader("Content-Type", "application/json");
JSONObject data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
};
RequestBody body = RequestBody.create(
MediaType.parse("application/json"), data.toString());
requestBuilder.method("put", body);
try (Response response = client.newCall(requestBuilder.build()).execute()) {
System.out.println(response.body().string());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import Foundation
let url = URL(string: "{server}/ExternalAccount/{appKey}/{id}")!
var request = URLRequest(url: url)
request.httpMethod = "put"
request.setValue("Bearer {your_access_token}", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let data = {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
}
let jsonData = try? JSONSerialization.data(withJSONObject: data)
request.httpBody = jsonData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
if let json = try? JSONSerialization.jsonObject(with: data) {
print(json)
}
}
}
task.resume()
|
返回结果
| {
"code": 200 // 状态码,
"data": false // 响应数据,
"error": "" // 错误信息
}
|
字段名 |
类型 |
描述 |
是否必填 |
code |
integer |
状态码 |
否 |
data |
boolean |
响应数据 |
否 |
error |
string |
错误信息 |
否 |
外部账号登录
基本信息
- 接口名称:外部账号登录
- 请求方式:POST
- 请求路径:/ExternalAccount/{appKey}/SignIn
请求参数
Path 参数
参数名 |
示例值 |
参数描述 |
是否必填 |
appKey |
- |
- |
是 |
Body 参数
参数名 |
类型 |
示例值 |
参数描述 |
是否必填 |
unionID |
string |
- |
UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符 |
是 |
platform |
string |
- |
平台,长度必须在1到20个字符之间,只能包含字母和数字 |
是 |
twoFactorCode |
string |
- |
双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字 |
否 |
示例代码
| import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
public class ApiClient {
public static void main(String[] args) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create("{server}/ExternalAccount/{appKey}/SignIn"))
.header("Authorization", "Bearer {your_access_token}")
.header("Content-Type", "application/json");
// 创建请求体数据
Map<String, Object> data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
};
ObjectMapper mapper = new ObjectMapper();
String jsonBody = mapper.writeValueAsString(data);
RequestBody body = RequestBody.create(
MediaType.parse("application/json"), jsonBody);
requestBuilder.method("post", HttpRequest.BodyPublishers.ofString(jsonBody));
try {
HttpResponse<String> response = client.send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import requests
url = "{server}/ExternalAccount/{appKey}/SignIn"
headers = {
"Authorization": "Bearer {your_access_token}",
"Content-Type": "application/json"
}
data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
}
response = requests.post(
url,
headers=headers,
json=data
)
print(response.json())
|
| package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main() {
client := &http.Client{}
var req *http.Request
var err error
data := {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
}
jsonBody, err := json.Marshal(data)
if err != nil {
panic(err)
}
req, err = http.NewRequest("post", "{server}/ExternalAccount/{appKey}/SignIn", bytes.NewBuffer(jsonBody))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer {your_access_token}")
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
|
| const axios = require('axios');
const data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
};
const config = {
method: 'post',
url: '{server}/ExternalAccount/{appKey}/SignIn',
headers: {
'Authorization': 'Bearer {your_access_token}',
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
|
| <?php
$url = "{server}/ExternalAccount/{appKey}/SignIn";
$headers = [
"Authorization: Bearer {your_access_token}",
"Content-Type: application/json"
];
$data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
};
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "post");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
|
| using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text;
using System.Text.Json;
class Program
{
static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer {your_access_token}");
HttpResponseMessage response;
var data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
};
var content = new StringContent(
JsonSerializer.Serialize(data),
Encoding.UTF8,
"application/json");
response = await client.postAsync("{server}/ExternalAccount/{appKey}/SignIn", content);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}
|
| require 'net/http'
require 'json'
uri = URI("{server}/ExternalAccount/{appKey}/SignIn")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::undefined.new(uri)
request["Authorization"] = "Bearer {your_access_token}"
request["Content-Type"] = "application/json"
data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
}
request.set_form_data(data)
response = http.request(request)
puts response.body
|
| const data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
};
fetch("{server}/ExternalAccount/{appKey}/SignIn", {
method: "post",
headers: {
"Authorization": "Bearer {your_access_token}",
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.catch(error => console.error(error));
|
| import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.json.JSONObject;
public class ApiClient {
private final OkHttpClient client = new OkHttpClient();
public void makeRequest() {
Request.Builder requestBuilder = new Request.Builder()
.url("{server}/ExternalAccount/{appKey}/SignIn")
.addHeader("Authorization", "Bearer {your_access_token}")
.addHeader("Content-Type", "application/json");
JSONObject data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
};
RequestBody body = RequestBody.create(
MediaType.parse("application/json"), data.toString());
requestBuilder.method("post", body);
try (Response response = client.newCall(requestBuilder.build()).execute()) {
System.out.println(response.body().string());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
| import Foundation
let url = URL(string: "{server}/ExternalAccount/{appKey}/SignIn")!
var request = URLRequest(url: url)
request.httpMethod = "post"
request.setValue("Bearer {your_access_token}", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let data = {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
}
let jsonData = try? JSONSerialization.data(withJSONObject: data)
request.httpBody = jsonData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
if let json = try? JSONSerialization.jsonObject(with: data) {
print(json)
}
}
}
task.resume()
|
返回结果
| {
"code": 200 // 状态码,
"data": {
"access_token": "",
"token_type": "",
"expires_in": "0"
},
"error": "" // 错误信息
}
|
字段名 |
类型 |
描述 |
是否必填 |
code |
integer |
状态码 |
否 |
data |
TokenModel |
- |
否 |
error |
string |
错误信息 |
否 |
数据结构
BooleanApiResponse
| {
"code": 200 // 状态码,
"data": false // 响应数据,
"error": "" // 错误信息
}
|
字段名 |
类型 |
描述 |
是否必填 |
code |
integer |
状态码 |
否 |
data |
boolean |
响应数据 |
否 |
error |
string |
错误信息 |
否 |
ExternalAccountBindRequest
| {
"unionID": "",
"platform": "",
"platformName": "",
"avatar": "",
"data": ""
}
|
字段名 |
类型 |
描述 |
是否必填 |
unionID |
string |
- |
是 |
platform |
string |
- |
是 |
platformName |
string |
- |
是 |
avatar |
string |
- |
否 |
data |
string |
- |
否 |
ExternalAccountPutRequest
| {
"avatar": "" // 头像,
"data": "" // 自定义数据,
"enable": false // 启用
}
|
字段名 |
类型 |
描述 |
是否必填 |
avatar |
string |
头像 |
否 |
data |
string |
自定义数据 |
否 |
enable |
boolean |
启用 |
否 |
ExternalAccountSignInRequest
| {
"unionID": "" // UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符,
"platform": "" // 平台,长度必须在1到20个字符之间,只能包含字母和数字,
"twoFactorCode": "" // 双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字
}
|
字段名 |
类型 |
描述 |
是否必填 |
unionID |
string |
UnionID,长度必须在1到50个字符之间,只能包含字母、数字、下划线和连字符 |
是 |
platform |
string |
平台,长度必须在1到20个字符之间,只能包含字母和数字 |
是 |
twoFactorCode |
string |
双因素认证代码,如果启用双因素认证登录,则必填,长度必须为6个字符,只能包含数字 |
否 |
TokenModel
| {
"access_token": "",
"token_type": "",
"expires_in": "0"
}
|
字段名 |
类型 |
描述 |
是否必填 |
access_token |
string |
- |
否 |
token_type |
string |
- |
否 |
expires_in |
integer |
- |
否 |
TokenModelApiResponse
| {
"code": 200 // 状态码,
"data": {
"access_token": "",
"token_type": "",
"expires_in": "0"
},
"error": "" // 错误信息
}
|
字段名 |
类型 |
描述 |
是否必填 |
code |
integer |
状态码 |
否 |
data |
- |
- |
否 |
error |
string |
错误信息 |
否 |
UserLogins
| {
"id": "0" // 唯一标识符,
"userID": "0" // 关联的用户ID,
"platformName": "" // 第三方平台名称,
"platform": "" // 第三方平台,
"unionID": "" // 第三方平台唯一标识,
"avatar": "" // 用户头像,
"data": "" // 扩展数据,
"enable": false // 启用,
"createDate": "" // 创建时间,
"lastUpdate": "" // 最后更新时间
}
|
字段名 |
类型 |
描述 |
是否必填 |
id |
integer |
唯一标识符 |
否 |
userID |
integer |
关联的用户ID |
否 |
platformName |
string |
第三方平台名称 |
否 |
platform |
string |
第三方平台 |
否 |
unionID |
string |
第三方平台唯一标识 |
否 |
avatar |
string |
用户头像 |
否 |
data |
string |
扩展数据 |
否 |
enable |
boolean |
启用 |
否 |
createDate |
string |
创建时间 |
否 |
lastUpdate |
string |
最后更新时间 |
否 |
UserLoginsListApiResponse
| {
"code": 200 // 状态码,
"data": [
{
"id": "0" // 唯一标识符,
"userID": "0" // 关联的用户ID,
"platformName": "" // 第三方平台名称,
"platform": "" // 第三方平台,
"unionID": "" // 第三方平台唯一标识,
"avatar": "" // 用户头像,
"data": "" // 扩展数据,
"enable": false // 启用,
"createDate": "" // 创建时间,
"lastUpdate": "" // 最后更新时间
}
] // 响应数据,
"error": "" // 错误信息
}
|
字段名 |
类型 |
描述 |
是否必填 |
code |
integer |
状态码 |
否 |
data |
array |
响应数据 |
否 |
error |
string |
错误信息 |
否 |
通用错误码