pushbullet 푸시 발송 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

pushbullet 푸시 발송 정보

PHP pushbullet 푸시 발송

본문

api가 쉽게 되어있어 급하게 만들어 보았습니다.

 

 

# pushbullet.class.php

<?php
class oh_push {
 
	var $token_key;
	var $push_url = 'https://api.pushbullet.com/v2/pushes';
 
	public function __construct($token_key) {
		$this->token_key = $token_key;
	}
 
	public function token() {
		return $this->token_key;
	}
 
	public function send($email=array(), $body='', $title='') {
 
		$type = 'note';
		foreach($email as $k=>$v) {
 
			$push_param = 'type='.$type.'&email='.$v.'&title='.$title.'&body='.$body;
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $this->push_url);
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $push_param);
			curl_setopt($ch, CURLOPT_HTTPHEADER, array('Access-Token: '.$this->token_key));
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			$response = curl_exec($ch);
			curl_close($ch);
		}
	}
}
 
$oh_push = new oh_push('토큰키');
$oh_push->send(array('이메일'), '내용', '제목');

 

 

토큰은 푸시불렛의 셋팅에서 받을수 있습니다.

추천
1

댓글 1개

감사합니다. 글 등록되는게 많지 않은 가족 홈페이지 만들어서.. 적용했는데 잘되네요.
GPF 의 post_write_update.tail 하고 post_write_comment_update.tail 이벤트에 보내게 등록을 해놓으니 글과 댓글을 놓칠일이 없겠습니다.

위 코드에서 약간 수정한거는.. note 타입이 아니라 link 타입으로 해서 게시글/댓글로 바로 가도록 해서 사용중입니다. 다른 분들.. 혹시 참고하시라고 남깁니다.

[code php]
    public function send($email=array(), $body='', $title='', $url='') {
        $type = 'link';
        foreach($email as $k=>$v) {
            $push_param = 'type='.$type.'&link='.urlencode($link).'&email='.$v.'&title='.urlencode($title).'&body='.urlencode($body);
[/code]
전체 5,352
개발자팁 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT