Child pages
  • User Forwarding with PHP
Skip to end of metadata
Go to start of metadata

This sample php code sets up a user's call forwarding

Sample Code
//Forwarding is being done using Restful API via Curl - here to demonstrate using both programming interfaces to accomplish a task
function addForwarding($user,$ext,$pass)
	//set up the forwarding rules (we append 7 because that tells sipx to dial on the nostalgic NEC system)
	//structured like this because we're actaully passing "XML" data to the page
	$rules = "
		  <type>At the same time</type> 
	//this URL does the magic - we're just passing everything to it
	$url = "https://sipx:8443/sipxconfig/rest/my/forward"; 
	//open up curl
	$ch = curl_init(); 
	//open the URL    
	curl_setopt($ch, CURLOPT_URL, $url);
	//we have to "PUT" the data to the server
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');  
	curl_setopt($ch, CURLOPT_POSTFIELDS, $rules); 
	//these two lines are only for servers with invalid SSL - hopefully you don't have that issue and can delete these
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

	//who are you? authorization errors if they are not a user yet
	curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
	//close our curl
  • No labels