<?php

	// https://www.aqcm.fr/v2/OVH_API/send_SMS_2.php

	require __DIR__ . '/vendor/autoload.php';
	use \Ovh\Api;
	
	$code_erreur =0;

	$aqcm_SMS_SERVICE = "OVH";

	//------------------------------------------------------------------------------
	if ( $aqcm_SMS_SERVICE == "OVH" ) {
		
		//------------------------------------------------------------------------------
		/*
		$end_point 			= $aqcm_SMS_end_point ;
		$application_key 	= $aqcm_SMS_application_key ;
		$application_secret	= $aqcm_SMS_application_secret ;
		$consumer_key			= $aqcm_SMS_consumer_key ;
		*/


		$end_point				= 'ovh-eu';

		// premières clefs créées
		$application_key		= "2730f57ecdb507a0";
		$application_secret	= "5950324d22a4da6e2a4761da31e1fc7f";
		$consumer_key			= "b6b80abb044d61e17332f49b968ef054";
		
		// KOKO2 : restriction d'adresse pour Contabo VPS : 173.212.252.5
		$application_key		= "230749ee31a13c13";
		$application_secret	= "1a17bc9c2182f48de322392f7a65f8d7";
		$consumer_key			= "616638dcf20abca58cc6a670fdfcc1d3";
		
		// AQCM05_CONTABO : restriction d'adresse pour Contabo VPS : 173.212.252.5
		$application_key		= "42cc6da5213c1f9a";
		$application_secret	= "d2bb9a63dee4bcab4846bc4a85099a46";
		$consumer_key			= "e80a66336493eba6a389503f9af21c8d";
		
		// AQCM05_CONTABO : restriction d'adresse pour LBN : 212.114.23.48
		$application_key		= "dd1af00b1a81a770";
		$application_secret	= "d1707dc176ea30aa5ba797da8b508786";
		$consumer_key			= "7b9a7e2ec69fdd23f390b5fee7add3b8";
		
		$sms_text				= "SMS de test avec OVH...";
		$admin_phone_number	= "+33761229502" ;
		
		//------------------------------------------------------------------------------
		$conn = new Api(	
							$application_key,
							$application_secret,
							$end_point,
							$consumer_key
						  );

		$smsServices = $conn -> get('/sms');
		
		$content = (object) array(
			"charset"				=> "UTF-8",
			"class"				=> "phoneDisplay",
			"coding"				=> "7bit",
			"message"				=> $sms_text,
			"noStopClause"		=> false,
			"priority"			=> "high",
			"receivers"			=> [ $admin_phone_number ],
			"senderForResponse"	=> true,
			"validityPeriod"		=> 2880
		);
	
		$resultPostJob = $conn -> post('/sms/'. $smsServices[0] . '/jobs', $content);

		$resultPostJob_string = print_r($resultPostJob, true);
		$resultPostJob_string = preg_replace('/\s+/', '', $resultPostJob_string);

		$resultPostJob = $conn->post('/sms/'. $smsServices[0] . '/jobs', $content);

		print_r($resultPostJob);

		$smsJobs = $conn->get('/sms/'. $smsServices[0] . '/jobs');

		print_r($smsJobs);
		
	}
				

?>