LoginSignup
1
2

More than 5 years have passed since last update.

Pushbulletにcronで通知を送る

Last updated at Posted at 2018-02-08

PushBullet

Pushbulletのプッシュ通知をiPhoneで表示させるための手順

https://bohbi-log.com/app/pushbullet/
普通にログインして通知OKにしただけではiPhoneに通知が来ない。

PushBullet-for-PHP

APIキーを取得

https://www.pushbullet.com/#settings/account
image.png
「Create Access Token」ボタンを押す。

表示されたキーを以下の'YOUR_API_KEY'に書く。

PushBullet.example.php
<?php

require 'PushBullet.class.php';

try {
  #### AUTHENTICATION ####
  // Get your API key here: https://www.pushbullet.com/account
  $p = new PushBullet('YOUR_API_KEY');

  #### Pushing to multiple devices
  // Push to all of your own devices, if you set the first argument to NULL or an empty string
  $p->pushNote(NULL, 'Some title', 'Some text');

} catch (PushBulletException $e) {
  // Exception handling
  die($e->getMessage());
}

?>

cronの設定

スターサーバーのライトプランなので、コントロールパネルからCRON設定。
コマンドの欄に/usr/bin/php に続けてフルパスでPHPを指定する。

<?php
echo __FILE__;
?>

でファイルのフルパスを調べておくといい。

image.png

これで好きな時間に好きな通知を送れる。
ランダムなメッセージを定期的にiPhoneに表示したくて作成した。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2