Rutvij Kulkarni
Rutvij Kulkarni

Reputation: 3

How Do I Use this data provided by Rapid API in php in my code?

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

Upvotes: 0

Views: 901

Answers (1)

Abhijit
Abhijit

Reputation: 941

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

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

enter image description here

Now it's works perfectly

Happy Programming

Thanks, AS

Upvotes: 1

Related Questions