diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 69da66fa99c..9a78e7a3dbf 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -78,6 +78,11 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = curl_setopt($ch, CURLOPT_POST, 1); // POST curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields } + elseif ($postorget == 'POSTALREADYFORMATED') + { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // HTTP request is 'POST' but param string is taken as it is + curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string + } elseif ($postorget == 'PUT') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' diff --git a/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php b/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php index 3bf45ea3848..67379019e0b 100644 --- a/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php +++ b/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php @@ -115,8 +115,30 @@ class InterfaceIFTTT extends DolibarrTriggers case 'THIRDPARTY_CREATED': dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - // TODO + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + // See https://platform.ifttt.com/docs/api_reference#realtime-api + + $arrayofdata=array(); + $arrayofdata['user_id']=$conf->global->IFTTT_USER_ID; + $arrayofdata['trigger_identity']=$conf->global->IFTTT_TRIGGER_IDENTITY; + $arrayofdata['name']='testabcdef'; + $arrayofdata['email']='testemailabcdef'; + + $url = 'https://realtime.ifttt.com/v1/notifications'; + + $addheaders=array( + 'IFTTT-Service-Key'=>'123', + 'Accept'=>'application/json', + 'Accept-Charset'=>'utf-8', + 'Accept-Encoding'=>'gzip, deflate', + 'Content-Type'=>'application/json', + 'X-Request-ID'=>getRandomPassword(true, null) + ) + + $result = getURLContent($url, 'POSTALREADYFORMATED', '', 1, $addheaders); + + $ok = 1; break; }