1
<?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.

asked Mar 13, 2014 at 5:15
2
  • Its non outputting anything. Commented Mar 13, 2014 at 5:16
  • do a vardump of $json and see whay you are getting Commented Mar 13, 2014 at 5:19

2 Answers 2

2

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.

answered Mar 13, 2014 at 5:19
Sign up to request clarification or add additional context in comments.

2 Comments

+1 - You can also suggest him to loop around to get all values not just a first one.
Thanks Rik , But seems like he needs just the URL .
0

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;
 ?>
answered Mar 13, 2014 at 6:13

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.