IFTTT
This commit is contained in:
parent
b91a458af4
commit
c444521abc
@ -78,6 +78,11 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
|
|||||||
curl_setopt($ch, CURLOPT_POST, 1); // POST
|
curl_setopt($ch, CURLOPT_POST, 1); // POST
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields
|
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')
|
elseif ($postorget == 'PUT')
|
||||||
{
|
{
|
||||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
|
||||||
|
|||||||
@ -115,8 +115,30 @@ class InterfaceIFTTT extends DolibarrTriggers
|
|||||||
case 'THIRDPARTY_CREATED':
|
case 'THIRDPARTY_CREATED':
|
||||||
dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user