help! algún programador bilingüe aquí... que hable python y php

  • Autor Autor fabgonber
  • Fecha de inicio Fecha de inicio
Al final de está página... hay un ejemplo en pyhton,
https://green-api.com/en/docs/api/sending/SendMessage/

¿Alguien me lo puede traducir a php? idealmente utilizando file_get_contents() en caso contrario curl.
Prueba con algo asi.

PHP:
<?php

$datos['chatId'] = '79001234567@c.us';
$datos['message'] = 'I use Green-API to send this message to you!';

$post_url = 'https://api.green-api.com/waInstance{{idInstance}}/SendMessage/{{apiTokenInstance}}';
$post_fields = json_encode($datos);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);

curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);

$resp = curl_exec($ch);
curl_close($ch);

print_r($resp);

?>
 
probaré... gracias!
 
Atrás
Arriba