Start a new topic

PHP | How to create an API watcher

You can use this snippet to create a new watcher (or webhook). Once the watcher is created, Agendize platform will notify the subscribed URL and send the JSON structure for each appointment booked. 

$apiKey = "";
$token = "";
$companyId = "";

//create a new cURL resource
$ch = curl_init("$companyId/appointments/watch?apiKey=$apiKey&token=$token");

//setup request to send json via POST
$data = array(
    'address' => ""
    // or: 'address' => ""
$payload = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

//execute the POST request
$result = curl_exec($ch);

//close cURL resource

You can also view all your existing watchers using the Watcher API.

Login or Signup to post a comment