Created
January 16, 2022 19:36
-
-
Save nfcg/13b996682dbbc5ec7afefe9f16a90195 to your computer and use it in GitHub Desktop.
Pushbullet Send SMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mobile_token = "o.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; | |
$mobile_iden = "xxxxxxxxxxxxxxxxxxxxxxx"; | |
function sendSMS($to, $message) | |
{ | |
global $mobile_iden, $mobile_token; | |
$to = "+351" . $to; | |
$data = [ | |
"data" => [ | |
"addresses" => [$to], | |
"message" => $message, | |
"target_device_iden" => $mobile_iden, | |
], | |
]; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://api.pushbullet.com/v2/texts"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); | |
$headers = []; | |
$headers[] = "Access-Token: " . $mobile_token; | |
$headers[] = "Content-Type: application/json"; | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
$result = curl_exec($ch); | |
$result = json_decode($result, true); | |
return $result; | |
curl_close($ch); | |
} | |
$data = sendSMS("xxxxxxxxx", "Hi, its me texting"); | |
echo '<pre>'; | |
echo $data[data][addresses][0] . '</br>'; | |
echo $data[data][message]; | |
echo '</pre>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Funciona correctamente