Bonjour à la communauté,
Je souhaite appeler l'API OVH depuis un google script. Cette dernière version fonctionne en 'GET' et en 'POST'. Je n'ai enfin plus de "Invalid signature". J'ai trouvé comment passer les paramètres BODY. Mais j'ai maintenant une dernière erreur que je n'arrive pas à passer : "[recipients] phoneNumber Data is not an array for an array type".
Pourtant le recipients semble bien être un array :
`$body = 'pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients=[ "0033972152245" ]'`
Mon google script est ci-dessous.
function ovh_api() {
/** to be changed by your account data */
$billingAccount= 'saxxxxxxx-ovh-1' //has to finised by '-ovh-1' or '-ovh-2' or '-ovh-3'...
$serviceName= '00339xxxxxxxx' //your fax number
/** "documentation" is here:
https://api.ovh.com/console/#/telephony/%7BbillingAccount%7D/fax/%7BserviceName%7D/settings/sendFax#POST
*/
$url = 'https://eu.api.ovh.com/1.0/telephony/'+$billingAccount+'/fax/'+$serviceName+'/settings/sendFax'
$method = 'POST'
$body = 'pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients=[ "0033972152245" ]'
/** All those $body failed with same message "phoneNumber Data is not an array for an array type"
$body='pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients=%5B0033972152245%5D'
$body = 'pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients=[ "+33972152245" ]'
$body='pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients=[0033972152245]'
$body='pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients=["0972152245"]'
$body='pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients=[0972152245]'
$body='pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients="[0033972152245]"'
$body='pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients="["0033972152245"]"'
$body='pdfUrl="http://www.africau.edu/images/default/sample.pdf"&recipients=0033972152245'
*/
/** to be changed by your own keys */
$ApplicationKey = 'xxx'
$ApplicationSecret = 'xxx'
$consumerKey = 'xxx'
$timestamp = UrlFetchApp.fetch('https://eu.api.ovh.com/1.0/auth/time')
/** hash documentation is here
https://docs.ovh.com/asia/en/api/first-steps-with-ovh-api
*/
$hash = "$1$"+makeSha1Hex($ApplicationSecret+"+"+$consumerKey+"+"+$method+"+"+$url+"+"+$body+"+"+$timestamp)
var response = UrlFetchApp.fetch($url, {
"method": $method,
"headers": {"X-Ovh-Application": $ApplicationKey, "X-Ovh-Signature": $hash, "X-Ovh-Consumer": $consumerKey, "X-Ovh-Timestamp": $timestamp},
"payload": $body
})
Logger.log(response)
}
/** Below are 3 functions to make SHA1 */
function makeSha1Hex (content) {
return byteToHexString(Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, content));
}
function byteToHexString (bytes) {
return bytes.reduce(function (p,c) {
return p += padLeading ((c < 0 ? c+256 : c).toString(16), 2 );
},'');
}
function padLeading (stringtoPad , targetLength , padWith) {
return (stringtoPad.length < targetLength ? Array(1+targetLength-stringtoPad.length).join(padWith | "0") : "" ) + stringtoPad ;
}
SMS Pro - Send fax with OVH API from Google Script. Error: [recipients] phoneNumber Data is not a
Related questions
- Envois SMS non délivrés - "No templates available"
28770
17.03.2020 09:55
- Saut de ligne dans un SMS envoyé avec API
20369
02.11.2017 07:31
- Click2Call.OVH : le plugin Click2Call et Click2SMS pour Mozilla Firefox est disponible!
18238
09.05.2017 18:24
- SMS : Durée de conservation SMS envoyés
17405
06.07.2017 12:01
- Format des fichiers CSV
16897
06.11.2016 21:00
- Portabilité numero de fax, ou/comment commander ?
16298
29.03.2019 13:31
- Nombre de caractère dans SMS
15805
01.08.2017 14:39
- Envoi de SMS via C# ne fonctionne plus
15767
14.11.2019 16:58
- API OVH - Modification des droits d'accès et de la durée de vie des identifiants
15632
21.11.2016 13:57
- Recevoir un SMS
13545
17.11.2016 23:23
Merci mille fois d'avance pour votre aide :)