Post
Topic
Board Service Discussion
Re: Tierion REST API HELP
by
achow101
on 05/08/2016, 17:26:37 UTC
Since it is a GET request, you don't need this line which is for post:
Code:
   curl_setopt($curl, CURLOPT_POST, true);

Furthermore, you are authenticating incorrectly. The authentication stuff should be in the headers, not in the body of the request.
Instead of
Code:
   $curl_post_data = array(
        "X-Username" => 'EMAIL ADDRESS',
        "X-Api-Key" => 'API KEY',
        );
   curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
you should have something like:
Code:
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "X-Username" => 'EMAIL ADDRESS',
        "X-Api-Key" => 'API KEY',
        ));

Note, I don't have experience with Tierion's data api. I just read the documentation you linked to, I highly suggest that you give that a read and fully understand how the API works, and how HTTP Requests work.