2

Is it possible to extract the value of "image_url" from this link

http://theapache64.xyz:8080/gpix/v1/gpix?keyword=honda%20civic%202009&limit=1

and display as <img src=""> using php?

VVN
  • 1,607
  • 2
  • 16
  • 25
Bernie Carpio
  • 321
  • 1
  • 3
  • 10

2 Answers2

1

You can fetch data from json as follow

<?php
$content = file_get_contents('http://theapache64.xyz:8080/gpix/v1/gpix?keyword=honda%20civic%202009&limit=1');

$arr = json_decode($content,true);

$url = $arr['data']['images'][0]['image_url'];

echo "<img src='".$url."'>";
?>
Bharat Dangar
  • 527
  • 4
  • 20
0

Thanks guys, I found a solution.

I will also post my solution here just in case other will encounter the same problem

    <?php

$json_file = file_get_contents('http://theapache64.xyz:8080/gpix/v1/gpix?keyword='.$combineurl.'&limit=1');

$jfo = json_decode($json_file);


$posts = $jfo->data->images;



foreach ($posts as $post) {
    ?>
    <img src="<?php echo $post->image_url; ?>" alt="" width="500">
    <?php
}
?> 
Bernie Carpio
  • 321
  • 1
  • 3
  • 10