0
<?php
    $get = file_get_contents("https://duckduckgo.com/i.js?q=love&s=1");
    $decode = json_decode($get, TRUE);
    foreach($decode['results'] as $res) {
        echo "".$res['image']."";
    }
?>

Nothing happens. What's wrong?

Warning: file_get_contents(https://duckduckgo.com/i.js?q=love&s=1) [function.file-get-contents]: failed to open stream: No such file or directory in /home01/rfep/nzfrka/home/mydomain/myfeed/sssfi.php on line 2

failed to open stream

Warning: Invalid argument supplied for foreach() in /home01/rfep/nzfrka/home/mydomain/myfeed/sssfi.php on line 4
Alina
  • 17
  • 2
  • `echo "
    ";` try this.. its working.. and showing the images as well
    – Nishant Solanki Feb 15 '16 at 12:46
  • 1
    Why do you have `echo "".$res['image']."";` There is not need for those quotes, you can just do `echo $res['image'];`. – Tom Feb 15 '16 at 12:47
  • You're probably getting an error message but you haven't configured your development box to report it. – Álvaro González Feb 15 '16 at 12:50
  • What do you mean by "nothing happens"? – arkascha Feb 15 '16 at 12:51
  • 1
    The code is somewhat crude, but it successfully extracts the image urls from the reply. Question is why apparently this does not appear to be working for you... It _mighty_ be that `"file_get_contents()` is blocked for external urls on your system. – arkascha Feb 15 '16 at 12:52
  • Everyone here, provided you answer to our questions... – arkascha Feb 15 '16 at 13:08
  • file_get_contents - successfully working on my website – Alina Feb 15 '16 at 13:13
  • echo ""; – Ravi Feb 15 '16 at 13:13
  • Only the script does not work. no mistakes – Alina Feb 15 '16 at 13:14
  • @Alina The script is working for me and also for the others. That's why you have to check why it doesn't work on your machine. So please check the given duplicate link how to get an error message of your PHP setup. After giving us this error message, we can help you hopefully. – Felix G. Feb 15 '16 at 14:50
  • It gives me an error! I changed the message – Alina Feb 15 '16 at 15:00
  • I this the only error message? Maybe your machine doesn't allow to get https-URLs via `file_get_contents()`. Please check this out: http://stackoverflow.com/questions/1975461/how-to-get-file-get-contents-work-with-https – Felix G. Feb 15 '16 at 15:25
  • @TIIUNDER Can you give a complete version of my script? – Alina Feb 15 '16 at 16:17
  • @Alina I used YOUR script out of your question and it is working for me. – Felix G. Feb 15 '16 at 17:24

0 Answers0