0

Cant find a solution

<?php

if (isset($_POST['submit'])) {

    $url = $_POST['url'];

    $rest_url = "http://api.facebook.com/restserver.phpformat=json&method=links.getStats&urls=" . urlencode($url);

    $json = json_decode(file_get_contents($rest_url), true);

    echo "Facebook Shares = " . $json[0][share_count];

    echo "Facebook Likes = " . $json[0][like_count];

    echo "Facebook Comments = " . $json[0][comment_count];
}
?>
Rotimi
  • 4,783
  • 4
  • 18
  • 27
EmBeePee
  • 11
  • 1
  • You need to have quotes round names like share_count - `]['share_count'];` – Nigel Ren Mar 24 '18 at 07:56
  • Looks like you missed a quesion-mark in your query. Should be `.../restserver.php?format=json&...` – Hitobat Mar 24 '18 at 10:39
  • @Nigel Ren Single Quotes works but i has another error like this "Undefined offset: 0 in C:\xampp\htdocs\Opinion_Mining\get_data.php on line 11" now this is what i get . :( help me pls. – EmBeePee Mar 25 '18 at 13:36
  • It may be that the JSON isn't an array, difficult to tell without the data. You could try just removing the `[0]`, but this is only a guess. – Nigel Ren Mar 25 '18 at 13:51

0 Answers0