Skip to content

Instantly share code, notes, and snippets.

@nfcg
Created January 16, 2022 19:36
Show Gist options
  • Save nfcg/13b996682dbbc5ec7afefe9f16a90195 to your computer and use it in GitHub Desktop.
Save nfcg/13b996682dbbc5ec7afefe9f16a90195 to your computer and use it in GitHub Desktop.
Pushbullet Send SMS
<?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>';
?>
@oscarsantiago
Copy link

Funciona correctamente

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment