使用JavaScript,我如何能够创建一个从PHP文件调用的函数,将键和属性添加到JSON文件中



所以我使用Discord.JS创建Discord Bot,并且我有一个命令

if(command === "addme") {
//code here
return message.reply(`Added ${message.author} to Database!`);
};

如何让它从一个向JSON文件添加键和属性的文件中调用PHP函数?

我不知道从哪里开始。我尝试过人们在这个网站上发布的其他问题的解决方案,但我找不到任何解决我问题的方法。

如果你能帮忙,谢谢!

这取决于您想在哪里调用php function

从表面上看,如果我没有错的话。。。似乎您不想与DiscordJS的API交互,而是与custom PHP function交互?

  1. 客户端

    • 是在浏览器上,iOS还是Android?-根据您所处环境的选择,有几种不同的方法
  2. 服务器端

    • 我假设您使用JS作为后端,您可以使用类似HTTP client的请求

等简单线路

var request = require('request');
request('https://saficloud.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the SafiCloud homepage.
});

就在你需要开始的地方,

干杯:(

最新更新