To verify that the username and password you have are valid and authorized, check the status by making a GET request to this URL:

https://api.field59.com/v2/user

Request

GET /v2/user HTTP/1.1
Accept: application/xhtml+xml
Authorization: username:password

Response

HTTP/1.1 200 OK
<?xml version="1.0"?>
<user>
      <username><![CDATA[johnsmith]]></username>
      <firstname><![CDATA[John]]></firstname>
      <lastname><![CDATA[Smith]]></lastname>
      <associatedaccount><![CDATA[ACCOUNT]]></associatedaccount>
      <accounts>
           <account><![CDATA[ACCOUNT]]></account>
      </accounts>
</user>

Code Example

In PHP, use curl to make the request.

<?php
try{
      $url = 'https://api.field59.com/v2/user';
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
      curl_setopt($ch, CURLOPT_USERPWD, 'username:password');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      $content = curl_exec($ch);
      com.dotmarketing.util.ServletResponseCharacterEncoding@6f2d5f9e = curl_getinfo($ch);
      print_r($content);
      print_r(com.dotmarketing.util.ServletResponseCharacterEncoding@6f2d5f9e);
} catch (Exception $e) {
    var_dump($e);
}
Share This