Code Examples
FreshToken Verification Example (JavaScript)
javascript
const url = "https://openapi.geelark.com/open/v1/phone/list";
const appToken = "your appToken";
// Generate UUID v4
var traceUUid = "yxxyxxxxyxyxxyxxyxxxyxxxyxxyxxyx".replace(
/[xy]/g,
function (c) {
var r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
}
);
var traceId = traceUUid.toUpperCase();
var data = {
page: 1,
pageSize: 10,
tags: ["tagNew"],
};
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
traceId: traceId,
Authorization: "Bearer " + appToken,
},
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((res) => {
console.log(res);
})
.catch((err) => {
console.error(err);
});Key Verification Example (JavaScript)
javascript
const CryptoJS = require("crypto-js");
const url = "https://openapi.geelark.com/open/v1/phone/list";
const appID = "your appID";
const apiKey = "your apiKey";
let timestamp = new Date().getTime().toString();
// Generate UUID
var traceUUid = "yxxyxxxxyxyxxyxxyxxxyxxxyxxyxxyx".replace(
/[xy]/g,
function (c) {
var r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
}
);
var traceId = traceUUid.toUpperCase();
// nonce is first 6 characters of traceId
var nonce = traceId.substring(0, 6);
// Generate SHA256 signature
var sign = CryptoJS.SHA256(appID + traceId + timestamp + nonce + apiKey)
.toString()
.toUpperCase();
var data = {
page: 1,
pageSize: 10,
};
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
appId: appID,
traceId: traceId,
ts: timestamp,
nonce: nonce,
sign: sign,
},
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((res) => {
console.log(res);
})
.catch((err) => {
console.error(err);
});Browser API Example (JavaScript)
The Browser API runs locally and requires no authentication.
javascript
const url = "http://localhost:40185/api/v1/browser/start";
var data = {
id: "123456789xxxx"
};
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((res) => {
console.log(res);
})
.catch((err) => {
console.error(err);
});Creating Automated Tasks
There are two types of automation tasks:
Account Management Tasks
Directly call the Add Task API to create account management tasks like login, warmup, profile editing, etc.
Video/Image Publishing Tasks
- First, upload your media files to get a resource URL
- Then call the Add Task API with the resource URL