如何在我的代码中使用PHP中Rapid API提供的数据? [英] How Do I Use this data provided by Rapid API in php in my code?

查看:127
本文介绍了如何在我的代码中使用PHP中Rapid API提供的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$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__"
  )
);

推荐答案

首先,我们需要从此链接下载unirest-php php库 https://github.com/Kong/unirest-php

First we need to download unirest-php php library From this link https://github.com/Kong/unirest-php

然后接下来创建php脚本并添加unirest

Then next create php script and add unirest

<?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);
 ?>

当我们运行这段代码时,我们会得到正确的响应输出

When we run this code then we get following proper output in response

现在可以正常使用

快乐编程

谢谢, AS

这篇关于如何在我的代码中使用PHP中Rapid API提供的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆