如何在代码中使用php中Rapid API提供的这些数据?
首先,我们需要从这个链接下载UnirestPHP库 然后接下来创建php脚本并添加unirest如何在代码中使用php中Rapid API提供的这些数据?,php,api,Php,Api,首先,我们需要从这个链接下载UnirestPHP库 然后接下来创建php脚本并添加unirest $response = Unirest\Request::get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/search?number=10&offset=0&query=burger", array( "X-Mashape-Key" => "__PRIVATE_KEY__
$response = Unirest\Request::get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/search?number=10&offset=0&query=burger",
array(
"X-Mashape-Key" => "__PRIVATE_KEY__",
"X-Mashape-Host" => "__REMOTE_HOST__"
)
);
当我们运行这段代码时,我们得到以下正确的输出作为响应
现在它的工作非常完美
快乐编程
谢谢,
作为
<?php
require_once 'unirest-php/src/Unirest.php'; // here we add path of Unirest.php
$response = Unirest\Request::get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/search?number=10&offset=0&query=burger",
array(
"X-Mashape-Key" => "privatekey",
"X-Mashape-Host" => "spoonacular-recipe-food-nutrition-v1.p.mashape.com"
)
);
echo "<pre>";
print_r($response);
?>