I want to send SMS via my Android phone. I found a promising api to do so called pushbullet
.
On section about connecting to it via cURL is says I should add custom header Access-Token: <your_access_token_here>'
. I added it in php but curl_exec
return false
. On PostMan I can create it without problems. My function that creates cURL looks like this:
public function getUrlContent($url, $post)
{
$data_string = '{
"push": {
"conversation_iden": "+3 34333333",
"message": "Hello!",
"package_name": "com.pushbullet.android",
"source_user_iden": "qwerqwerqwer",
"target_device_iden": "erqwer",
"type": "messaging_extension_reply"
},
"type": "push"
}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Access-Token: xxxxxxxxxxxxxxxxxxxx',
'Content-Length: '.strlen($data_string), )
);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}