首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用JavaScript,我如何能够创建一个从PHP文件调用的函数来向JSON文件添加键和属性?

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

Stack Overflow用户
提问于 2018-08-01 07:46:43
回答 1查看 186关注 0票数 -1

所以我使用Discord.JS来创建一个不一致的机器人,我有一个命令

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

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

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

如果你能帮上忙,谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-01 08:08:00

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

从表面上看,如果我没记错的话...看起来您并不想与DiscordJScustom PHP function交互,而是希望与API交互

  1. 客户端

- Is it on a browser ,iOS or Android? - There are couple of different approaches depending on the choice of environment you are in. 

  1. 服务器端

- I assume you are using JS as your back-end , you could use an `HTTP client` like [request](https://github.com/request/request)

简单的代码行,比如

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.
});

就是你需要开始的地方,

干杯:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51623535

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档