api - 将 CURL 与 discord.js 和 5sim API 一起使用
问题描述
我试图为我的不和谐机器人发出命令,所以我可以通过他们的 api 从 5sim 获取任何类型帐户的验证码......我认为我非常接近,因为我的一些代码在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: {
Authorization: "Bearer MYAUTHORIZATIONTOKENHERE",
Accept: "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:\Users\manof\Desktop\Main Bots\Celly Bot\commands\buy.js:8
const response = curl "https://5sim.net/v1/user/buy/activation/cambodia/any/discord",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected string
所有帮助将不胜感激!
解决方案
你能试试吗
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();
因为你的语法不正确。
推荐阅读
- git - GIT:在你的根文件夹中使用 CRA 应用程序,我怎样才能正确推送到 git?
- openssl - 当我使用 openssl -starttls 命令连接 smtp 时,我无法停止编写电子邮件正文。(分 7)
- c# - 使用接口变量在域模型中潜在地保存不同类的对象是否合法?
- java - 如何 1) 删除 2) 使用正则表达式从 Java 字符串中获取列表项标签?
- java - Thread.sleep 没有抛出 InterruptedException
- elasticsearch - ElasticSearch 文档有存档机制吗?
- python - 将字符串传递给 Invoke
- javascript - p5.js:在 html 元素之上渲染画布而不阻塞鼠标交互
- apache-spark - Pyspark:org.apache.spark.memory.SparkOutOfMemoryError:无法获取 116 字节的内存,得到 0
- json - 如何将新对象添加到现有的 json 数据