Make sure that you have php-xml module installed and enabled in php.ini
.
You can also change response format to json which is easier to handle. In that case you have to only add &format=json
to url query string.
$rest_url = "http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls=".urlencode($source_url);
And then use json_decode()
to retrieve data in your script:
$result = json_decode($content, true);
$fb_like_count = $result['like_count'];