The official Adfly API has very poor documentation. So, they say that to make a request you have 2 auth types:
Good, at the moment I follow all the steps but in a moment I cant understand what's going on.
My code:
function computehash(key, update){
const hash = crypto
.createHmac(`sha256`, key)
.update(serialize(update))
.digest(`base64`);
console.log(hash)
return hash
}
async function account(){
let url = "https://api.adf.ly/v1/account"
let timestamp = Math.round(new Date().getTime()/1000)
//let toencode = "_user_id="+userId+"&_api_key="+apiKey+"&_timestamp="+timestamp
let data = {
"_user_id": userId,
"_api_key": apiKey,
"_timestamp": timestamp//,
//"_hash": computehash(privateKey, dad)
}
dad._hash = computehash(privateKey, data)
console.log(serialize(data))
let res = await axios.post(url, serialize(dad), headers)
console.log(res.data)
}
account();
Here's the API documentation and some examples: