Webhooks v.2 not triggering


#1

I searched through the forums to try to find a topic or thread that was directly related. I created a php file that uses the new API calls using PHP Curl and PUT to lock and unlock my door.

When I load the address on my web server via a browser it works perfectly but when I unlock my door I wait, and wait and wait and it never triggers. Ive checked and re-checked my api settings but it never fires. Any help is appreciated.

When I run it manually I get the following output

{“id”:“xxxxxxxxxx”,“name”:“11201LW”,“state”:“lock”,“connected”:true,“button_type”:“slider”,“last_heard_from”:null,“last_online”:“2017-01-01T18:21:45Z”,“last_offline”:null,“next_wake”:null}

Here is my PHP code

<?php

class Curl {

public function get($url){

	$ch = curl_init($url);                                                                      
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");                                                                 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                                                                    
	$result = curl_exec($ch);
	return $result;
}

public function post($url, $data_string){

	$ch = curl_init($url);                                                                      
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
	curl_setopt($ch, CURLOPT_FAILONERROR, true);                                                                    
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
	    'Content-Type: application/json',                                                                                
	    'Content-Length: ' . strlen($data_string))                                                                       
	);                                                                                                                   
	 
	$result = curl_exec($ch);
	return $result;
}

public function put($url, $data_string){

	$ch = curl_init($url);                                                                      
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); 
	curl_setopt($ch, CURLOPT_FAILONERROR, true);                                                                    
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
	    'Content-Type: application/json',                                                                                
	    'Content-Length: ' . strlen($data_string))                                                                       
	);                                                                                                                   
	 
	$result = curl_exec($ch);
	return $result;
}

public function delete($url, $data_string){

	$ch = curl_init($url);                                                                      
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
	curl_setopt($ch, CURLOPT_FAILONERROR, true);                                                                    
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
	    'Content-Type: application/json',                                                                                
	    'Content-Length: ' . strlen($data_string))                                                                       
	);                                                                                                                   
	 
	$result = curl_exec($ch);
	return $result;
}

}

$curl = new Curl;
curl_setopt($curl, CURLOPT_TIMEOUT,5);//timeout in seconds
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); 

$data_string = '{"state" : "lock"}';
$url = "https://api.lockitron.com/v2/locks/XXXXXX?access_token=XXXXX";
echo $curl->put($url, $data_string);

?>

#2

@Jon_Brown I just tested and I received a webhook within about 2 seconds of the lock action completing.

To verify, does the PHP script successfully complete a lock or unlock command (as confirmed by a 200 response code or a new activity)?