问题描述
我需要与网站集成第三方API,我不知道甚至从哪里开始.我只有这个端点 -
获取当前的入住率
https://api.abcfinancial.com/rest/{clubnumber}/俱乐部/checkins/占用
CurrencoCupancy返回俱乐部中当前成员数.
MaxOccupancy返回俱乐部允许的最大成员数.
currentoccupancypercentage返回俱乐部成员的当前百分比.
我需要获得当前的占用,并在滑块革命幻灯片上显示它.如何做到这一点或任何事情的任何帮助.
推荐答案
如果您要在前端专门使用它,可以使用JavaScript查看API呼叫.使用 fetch api将在这种情况下工作.您可以查看脚本并在functions.php文件中浏览它.
如果您需要在服务器端执行它,可以使用 curl get_file_contents访问API.
使用服务器侧选项,页面通常需要更长的加载,因为您不会回复对您网站的响应,直到服务器击中API.使用JavaScript选项,您可以查看API而不阻止您的其余部分.
问题描述
I need to integrate a 3rd party API with a website and I have no idea where to even start. I just have this endpoint-
GET Current Occupancy
https://api.abcfinancial.com/rest/{clubNumber}/clubs/checkins/occupancy
currentOccupancy Returns the current number of members in the club.
maxOccupancy Returns the maximum number of members allowed in the club.
currentOccupancyPercentage Returns the current percentage of members in the club.
I need to get the current occupancy and show it on the slider revolution slide. Any help of how to do this or anything would be greatly appreciated.
推荐答案
If you're looking to use it specifically on the front end, you can look to implement the API call using Javascript. Using the Fetch API would work in that case. You would look to add the script and enqueue it within your functions.php file.
If you need to do it on the server side, you can use either cURL or get_file_contents to access the API.
With the server side option, the page will generally take longer to load as you are not getting back a response to the your site until the server has hit your API. With the Javascript option, you can look to hit the API without blocking the rest of your page.