课程: Level Up: PHP

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Retrieve and display data from a provided REST API

Retrieve and display data from a provided REST API - PHP教程

课程: Level Up: PHP

Retrieve and display data from a provided REST API

- Back in the late nineties the way to make websites work together was by linking them. But today there are much more powerful ways integrations, automations, and open data. All of this information is available through APIs commonly REST APIs and send JSON back. With PHP we can quickly get JSON information back from an API and convert it to a usable array. And that's exactly what you'll do for this challenge. The fantastic xkcd has a completely open JSON API at xkcd.com/json.html. It provides two links, one for the latest comic and one where you pass a comic number to it and it returns that specific comic. You're going to build a page that displays a randomly selected xkcd comic. Here are the requirements. Use the provided xkcd API linked on the screen here. Get the total number of comics, randomly generate a number from one to the total number of comics and make an API call to that specific comic. Then print the title…

内容