How to use CiviCRM REST API in external PHP code
I use CURL to call rest api. Here is the snippet you can ignore/remove many lines that sets curl variable.

$url = 'http://domain.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=getsingle&amp;api_key=HR76BS710C&amp;key=8c1cf9913fd674e08c8f27804334eb5a&amp;json={"id":1}';

$ch = curl_init();
//http://php.net/manual/en/function.curl-setopt.php
//$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_TIMEOUT, 5);
//curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_ENCODING, "");

//for debugging?
curl_setopt($ch, CURLOPT_VERBOSE, true);

$data = curl_exec($ch);
curl_close($ch);
$obj = json_decode($data);


HTH

Pradeep