Reputation: 165
<?php
$url = "http://api.giphy.com/v1/gifs/search?q=hello&api_key=dc6zaTOxFJmzC";
$content = file_get_contents($url);
$json = json_decode($content);
echo $json->images[0]->fixedheight->url[0];
?>
I've tried everything- even reading it as an array and it doesn't work.
Any help?
So sorry to bother! Thanks again.
Upvotes: 1
Views: 193
Reputation: 307
use this
<?php
$url = "http://api.giphy.com/v1/gifs/search?q=hello&api_key=dc6zaTOxFJmzC";
$content = file_get_contents($url);
$json = json_decode($content);
echo "<pre>";
print_r($json->data[0]->images->fixed_height->url);
exit;
?>
Upvotes: 0
Reputation: 68476
You should access it this way
echo $json->data[0]->images->fixed_height->url;
That is beacause the $data
is an array , and it has an object
as its first parameter.
Upvotes: 2