Accessing XML

Accessing XML using PHP:

To access the API include this function to your code:

  1. //Get data from specific API
  2. //$base_url = URL of API
  3. //$accesskey = accesskey for the API
  4. //$privatekey = privatekey for the API
  5. function getdata($base_url, $accesskey, $privatekey)
  6. {
  7. $ch = curl_init();
  8. curl_setopt($ch, CURLOPT_URL, $base_url);
  9. curl_setopt($ch, CURLOPT_USERPWD, $accesskey . ':'.$privatekey);
  10. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  11. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  13. $data = curl_exec($ch);
  14. curl_close($ch);
  15. echo $data;
  16. }

How to use:

-Call the function getdata by passing API url, accesskey and private key

Example:

  1. getdata("http://api.agentaccount.com/api/properties?office_id=15/","d5d69029db49466fa213dd6e04af284906161456", "24d80380e213c8eec87c662996d02c74da0bbf81");