Creating a simple PHP Client

I am trying to create a simple client on a web server using PHP and the php curl functions
Each time I get the response '{“errors”:[{“message”:“The client is not authorized.”}]}

Any suggestions about what I am doing wrong would be welcome!

My code is as follows

<?php $ch = curl_init("https://api.rach.io/1/public/person/info"); $fp = fopen("rachio.json", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, "Authorization: Bearer my-api-code=here"); curl_exec($ch); if(curl_error($ch)) { fwrite($fp, curl_error($ch)); } curl_close($ch); fclose($fp);

Header command needs an array, also the command itself was wrong, you need CURLOPT_HTTPHEADER

<?php $api = “xyz”; $ch = curl_init("https://api.rach.io/1/public/person/info"); $fp = fopen("rachio.json", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $api"]); curl_exec($ch); if(curl_error($ch)) { fwrite($fp, curl_error($ch)); } curl_close($ch); fclose($fp);

============================================================================
Thank you Gene!!! That was exactly what I’d gotten wrong. I’ve tried it with your changes and all is working well and I’m able to retrieve my zone/schedule information as json, which is what I needed.