Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
work on a Json!
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / General / General Chat

2021-12-29 17:01:44
Hello,
here is a json type api url.
I would like to know how to put the results in a php page, please.
https://radio.neri-info.com/api/nowplaying/6
If you can give me an example that would be nice!
Happy New Year.
2021-12-29 18:22:44
This is a broad question but most important lets start by getting data - then you can insert into database

i use website posted above for example  :thumb  make test.php then visit yoururl/test.php

<?php
   function url_get_contents($Url)
   {
       if (!function_exists('curl_init')) {
           header("HTTP/1.0 403 Forbidden");
           echo '<html><head><title>Forbidden</title> </head><body> <h1>Forbidden</h1>CURL is not installed!.<br> </body></html>';
           die();
       }
       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, $Url);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       $output = curl_exec($ch);
       curl_close($ch);
       return $output;
   }

$json_data = url_get_contents("https://radio.neri-info.com/api/nowplaying/6" );
$data = json_decode($json_data, true);
foreach($data as $key => $value){
   var_dump($key);
   echo '<br>';
   var_dump($value);
   echo '<br>';
}


Last edited by M-jay warn on 2021-12-29 20:57:30
2021-12-30 05:30:37
hello M-jay
blank page

Warning: Invalid argument supplied for foreach()

Last edited by SLy on 2021-12-30 05:57:49
2021-12-30 05:56:51
try add this at top under <?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
2021-12-30 05:59:19
Warning: Invalid argument supplied for foreach()
Quote:
foreach($data as $key => $value){
  var_dump($key);
  echo '<br>';
  var_dump($value);
  echo '<br>';
}
Last edited by SLy on 2021-12-30 06:09:04
2021-12-30 10:42:53
Above
$data = json_decode($json_data, true);


Add
var_dump($json_data); die();
2021-12-30 15:42:44
bool(false)

I specify
Mysql version: 5.5.62-0 + deb8u1
PHP version: 5.6.40-0 + deb8u12
Apache version: Apache / 2.4.10 (Debian)
Last edited by SLy on 2021-12-30 15:57:22
2021-12-30 18:01:03
better use javascript to display json data
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728