我想為我的discord機器人做一個命令,這樣我就可以通過5sim的api獲得任何型別的賬戶的驗證碼。我想我已經很接近了,因為我的一些代碼在https://reqbin.com/req/c-vdhoummp/curl-get-json-example...中起作用了。但我在實作它的命令中遇到了困難!這是我第一次使用Curl,所以我不是很熟悉,但我想知道是否有人能給我一些幫助來解決我的破代碼?
const Discord = require(`discord.js`)
const curl = require(`curl`)
module.exports = {
name: `buynumber`,
description: `buys a phone number!`,
async execute(message) {
const response = curl 'https://5sim.net/v1/user/buy/activation/cambodia/any/yahoo',
{
headers: {
授權。"Bearer MYAUTHORIZATIONTOKENHERE"。
接受。"application/json"
}
}; data = await response.json()
message.channel.send(data.number)
}}
目前我面臨的錯誤是
[Sun Sep 12 2021 21:26:16] [LOG] Initializing Startup!
[Sun Sep 12 2021 21:26:16] [ERROR] (node:12692) UnhandledPromiseRejectionWarning: C:UsermanofDesktopMain BotsCelly Botcommandsuy.js:8
const response = curl "https://5sim.net/v1/user/buy/activation/cambodia/any/discord",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 未預期的字串
非常感謝所有的幫助!
uj5u.com熱心網友回復:
你能試著做一下嗎
const response = curl('https://5sim.net/v1/user/buy/activation/cambodia/any/yahoo', {
headers: {
Authorization: "Bearer MYAUTHORIZATIONTOKENHERE"。
Accept: "application/json".
}
});
const data = await response.json()。
因為你的語法不正確。
uj5u.com熱心網友回復:
你試圖呼叫curl包中的函式curl.get,因此它要求你通過()來呼叫它,這是一個簡單的語法錯誤,可以像這樣解決:
let data;
const response = curl.get('https://5sim.net/v1/user/buy/activation/cambodia/any/yahoo'/span>,
{
headers: {
Authorization: "Bearer MYAUTHORIZATIONTOKENHERE"。
Accept: "application/json".
}
});
data = await response.json()
我建議你閱讀給出的例子這里
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/319765.html
標籤:
上一篇:用PHP執行curl請求
