コード例 #1
1
ファイル: PushMessage.php プロジェクト: nawrasg/Atlantis
 public function sendMessageDevice($title, $message, $device)
 {
     $gcpm = new GCMPushMessage($this->apiKey);
     $bdd = getBDD();
     $req = $bdd->query("SELECT at_gcm.gcm FROM at_gcm JOIN at_devices ON at_gcm.mac = at_devices.mac JOIN at_users ON at_devices.username = at_users.id WHERE at_gcm.mac = '{$device}' LIMIT 1");
     $data = $req->fetch();
     if (!$data) {
         return;
     }
     $gcpm->setDevices($data['gcm']);
     $response = $gcpm->send($message, array('title' => $title));
     return $response;
 }
コード例 #2
0
ファイル: general.php プロジェクト: shaffan1/categoriesapp
 public function sendAndroidNotification($devices, $data)
 {
     $gcpm = new GCMPushMessage(GOOGLE_API_KEY);
     $gcpm->setDevices($devices);
     $response = $gcpm->send($data);
     return $response;
     //$response = $gcpm->send($message, array('title' => 'Test title'));
 }
コード例 #3
0
ファイル: GCMP.php プロジェクト: vtrmantovani/sigma
 public function teste()
 {
     $devices = array('fkLoMHxo8Io:APA91bH-kCWLZGgPha6Ui0_ktaQf5f-QO9JCduoJXnCtPdzspqS3zCmjokuc-Zqdj12ZwqJgmJFkCjvQ5b82AH2_kzLmqyQzwJPfclK1JD3r1N08tTTX50RkrTX65sZuM4r9BxG5G2fp');
     $message = "The message to send";
     $this->load->library('GCMPushMessage');
     $gcpm = new GCMPushMessage();
     $gcpm->setserverApiKey('AIzaSyBbo9uVQdKqGb8FJ5EHvfAP7iht9TwgUQ4');
     $gcpm->setDevices($devices);
     $response = $gcpm->send($message, array('title' => 'Test title'));
     var_dump($response);
     die;
 }
コード例 #4
0
function startPushCheck()
{
    global $dbconn_mysql;
    global $dbconn;
    global $apiKey;
    $gcpm = new GCMPushMessage($apiKey);
    $query = $dbconn_mysql->prepare("SELECT ls.match_id, ls.player_id, ls.name, ls.time, upn.device_token, ls.team_id, upn.device_type AS device_type FROM live_scorers ls, users_push_notifications upn WHERE ls.team_id=upn.team_id");
    $query->execute();
    $data = $query->fetchAll();
    foreach ($data as $gameData) {
        $name = $gameData['name'];
        $tid = $gameData['team_id'];
        $mid = $gameData['match_id'];
        $suf = suffixAddition($gameData['time']);
        $tnquery = $dbconn->prepare("SELECT * FROM teams WHERE id = ? LIMIT 1");
        $tnquery->execute(array($tid));
        $rowtn = $tnquery->fetchAll();
        $query = $dbconn_mysql->prepare("SELECT * FROM sent_pushes WHERE team_id=? AND match_id=? AND time=? AND player_name=?");
        $query->execute(array($tid, $mid, $suf, $name));
        $row = $query->fetchAll();
        $co = count($row);
        //$co=0;
        if ($co == 0) {
            $tn = $rowtn[0]['name'];
            if (!$tn) {
                $message = "{$name} just scored in the {$suf} minute!";
            } else {
                $message = "{$name} ({$tn}) just scored in the {$suf} minute!";
            }
            if ($gameData['device_type'] == 'ANDROID') {
                $devices = array($gameData['device_token']);
                $gcpm->setDevices($devices);
                $response = $gcpm->send($message, array());
            } else {
                sendAPNSProduction($gameData['device_token'], $message);
            }
            $query = $dbconn_mysql->prepare("INSERT INTO sent_pushes (team_id, match_id, time, player_name) VALUES (?,?,?,?)");
            $query->execute(array($tid, $mid, $suf, $name));
        }
    }
}
コード例 #5
0
function send_push($key, $device, $message, $author, $title)
{
    $an = new GCMPushMessage($key);
    $devices = $device;
    $ar = array();
    $ar['message'] = $message;
    $ar['author'] = $author;
    $ar['title'] = $title;
    $an->setDevices($devices);
    $message = "";
    $response = $an->send($message, $ar);
    return $response;
    //	$an = new GCMPushMessage("AIzaSyAL_U7vjf5hXDHVESU04tJtEldBRaVaEIY");
    //	$devices = "APA91bE65g_vCaZ2lLxW2JzIXyoKqXzdrsBcUqwUBdpK02GHxQVic-uTATHu6kthptXP1OpRkVf1lbxHAyIrbdxNGuK0NnrSB7GQDSpBNzvfo8CT7ZoPQsSJe-C_YIFUDHAyotr7_A2v";
    //	$ar = array();
    //	$ar['message'] = "Um novo chamado na sua região!";
    //	$ar['author'] = "Bradesco";
    //	$ar['title'] = "DMP Brasil";
    //	$an->setDevices($devices);
    //	$message = "";
    //	$response = $an->send($message,$ar);
    //echo "\n$response\n";
    //print_r($message);
}
コード例 #6
0
require_once '../inc/GCMPushMessage.php';
require_once '../drivers/GcmDriver.php';
// Get Data
@($title = $_GET['title']);
@($desc = $_GET['desc']);
@($date = $_GET['date']);
@($lat = $_GET['lat']);
@($long = $_GET['long']);
// List Device
$GcmDriver = new GcmDriver();
$response = $GcmDriver->getDeviceIDList();
$get_device = json_decode($response)->data;
// Generate JSON data
$col['title'] = $title;
$col['desc'] = $desc;
$col['date'] = $date;
$col['time'] = "";
$col['latitude'] = $lat;
$col['longitude'] = $long;
$api['err_no'] = 0;
$api['err_msg'] = "Success";
$api['action_type'] = "events";
$api['data'] = $col;
$m = json_encode($api);
$apiKey = "AIzaSyA0m3PU8hRFB8XYM_ApFGWzH2Z0I06LpgA";
$devices = $get_device;
$message = $m ? $m : "OMAPSLAB";
$gcpm = new GCMPushMessage($apiKey);
$gcpm->setDevices($devices);
$response = $gcpm->send($message, array('title' => 'Test title'));
var_dump($response);
コード例 #7
0
ファイル: OrdemServico.php プロジェクト: vtrmantovani/sigma
 public function finalizarOrdemServico()
 {
     $idOrdemServico = $this->uri->segment(3);
     $statusOrdemServico = $this->uri->segment(4);
     if ($idOrdemServico != null && $statusOrdemServico != null) {
         if ($statusOrdemServico == 3 || $statusOrdemServico == 4) {
             $dadosCabec = array('data_finalizacao' => date("Y-m-d"), 'finalizado' => 1);
             $ordemservico = $this->ordemservico_model->get_ordemServico_byid($idOrdemServico)->row();
             $this->ordemservico_model->update_ordemServico($dadosCabec, array('id_ordem_servico' => $idOrdemServico));
             if ($ordemservico != NUll) {
                 $id_cliente = $ordemservico->id_cliente;
                 $cliente = $this->cliente_model->get_cliente_by_id($id_cliente)->row();
                 if ($cliente != NULL) {
                     if ($cliente->token != NULL) {
                         $gcpm = new GCMPushMessage();
                         $gcpm->setserverApiKey('AIzaSyBbo9uVQdKqGb8FJ5EHvfAP7iht9TwgUQ4');
                         $message = "Olá " . $cliente->nome . ' sua ordem de serviço foi finalizada';
                         $gcpm->setDevices(array($cliente->token));
                         $gcpm->send($message, array('title' => 'Sigma'));
                     }
                 }
             }
             $this->session->set_flashdata('message_success', 'Ordem de serviço finalizado com sucesso!');
         }
     }
     redirect('OrdemServico/listar', 'refresh');
 }
コード例 #8
0
ファイル: Orcamento.php プロジェクト: vtrmantovani/sigma
 public function finalizarOrcamento()
 {
     $idOrcamento = $this->uri->segment(3);
     $statusOrcamento = $this->uri->segment(4);
     if ($idOrcamento != NULL && $statusOrcamento != NULL) {
         if ($statusOrcamento == 4 || $statusOrcamento == 5) {
             $dadosCabec = array('data_finalizacao' => date("Y-m-d"));
             $this->orcamento_model->update_orcamento($dadosCabec, array('id_orcamento' => $idOrcamento));
         } else {
             if ($statusOrcamento == 6) {
                 $dadosCabec = array('data_finalizacao' => date("Y-m-d"), 'finalizado' => 1);
                 $dadosOrcamento = $this->orcamento_model->get_orcamento_byid($idOrcamento)->row();
                 $dadosCabec = array('id_orcamento' => $idOrcamento, 'id_status' => 1, 'id_cliente' => $dadosOrcamento->id_cliente, 'id_tipo_pagamento' => $dadosOrcamento->id_tipo_pagamento, 'data_criacao' => date("Y-m-d"), 'data_finalizacao' => null, 'desconto_adicional' => $dadosOrcamento->desconto_adicional, 'desconto_total' => $dadosOrcamento->desconto_total, 'total_bruto' => $dadosOrcamento->total_bruto, 'total_liquido' => $dadosOrcamento->total_liquido, 'data_prevista_finalizacao' => date("Y-m-d", strtotime("+2 day")), 'observacoes' => $dadosOrcamento->observacoes, 'finalizado' => 0, 'deletado' => 0);
                 $id = $this->ordemservico_model->insert_ordemServico($dadosCabec);
                 $dadosOrcamentoProduto = $this->orcamentoproduto_model->get_orcamentoProduto_byid($idOrcamento)->result();
                 foreach ($dadosOrcamentoProduto as $orcamentoProduto) {
                     $dadosProduto = array('id_ordem_servico' => $id, 'id_produto' => $orcamentoProduto->id_produto, 'quantidade' => $orcamentoProduto->quantidade, 'desconto' => $orcamentoProduto->desconto, 'preco_venda' => $orcamentoProduto->preco_venda, 'preco_cobrado' => $orcamentoProduto->preco_cobrado, 'deletado' => 0);
                     $this->ordemServicoproduto_model->insert_ordemServicoProduto($dadosProduto);
                     $this->atuEstProdutoOrcamento($orcamentoProduto->id_produto, $orcamentoProduto->quantidade, "");
                 }
                 $dadosOrcamentoServico = $this->orcamentoservico_model->get_orcamentoServico_byid($idOrcamento)->result();
                 foreach ($dadosOrcamentoServico as $orcamentoServico) {
                     $dadosServico = array('id_ordem_servico' => $id, 'id_servico' => $orcamentoServico->id_servico, 'preco_cobrado' => $orcamentoServico->preco_cobrado, 'deletado' => 0);
                     $this->ordemservicoservico_model->insert_ordemServicoServico($dadosServico);
                     $id_cliente = $dadosOrcamento->id_cliente;
                     $cliente = $this->cliente_model->get_cliente_by_id($id_cliente)->row();
                     if ($cliente != NULL) {
                         if ($cliente->token != NULL) {
                             $gcpm = new GCMPushMessage();
                             $gcpm->setserverApiKey('AIzaSyBbo9uVQdKqGb8FJ5EHvfAP7iht9TwgUQ4');
                             $message = "Olá " . $cliente->nome . ' seu orçamento foi finalizado';
                             $gcpm->setDevices(array($cliente->token));
                             $gcpm->send($message, array('title' => 'Sigma'));
                         }
                     }
                 }
             }
         }
         $this->session->set_flashdata('message_success', 'Orçamento finalizado com sucesso! Gerado ordem de serviço número: ' . $id . '!');
     }
     redirect('OrdemServico/visualizar/' . $id, 'refresh');
 }
コード例 #9
0
ファイル: core.php プロジェクト: nick-catanchin-ie/common
 /**
  * push notiication using GCM
  * @param  array/string $device_id devices
  * @param  string $message   
  * @param  array $data      
  * @return bool            
  */
 public static function push_notification($device_id, $message, $data = NULL)
 {
     if (core::config('general.gcm_apikey') != NULL) {
         require_once Kohana::find_file('vendor', 'GCMPushMessage', 'php');
         $gcpm = new GCMPushMessage(core::config('general.gcm_apikey'));
         $gcpm->setDevices($device_id);
         try {
             return $gcpm->send($message, $data) ? TRUE : FALSE;
         } catch (Exception $e) {
             return FALSE;
         }
     }
     return FALSE;
 }
コード例 #10
0
ファイル: API.php プロジェクト: korkiss/bubble_ship
 /**
  * Отсылка сообщения. Могут быть разных видов
  * @param $request[token] токен для определения пользователя
  * @param $request[type] тип сообщения
  * @param $request[reciepent] имя пользователя или группы получателя 
  * @param $request[data] содержание сообщения
  */
 function sendMessage($request)
 {
     $userId = $this->_verifyToken($request);
     if (empty($userId)) {
         throw new Exception("User is not authorized");
     }
     if (empty($request['type'])) {
         throw new Exception("Message type Unknown");
     }
     if (empty($request['type'])) {
         throw new Exception("Message type Unknown");
     }
     // Не надо двойные сообщения посылать
     $messageExists = DBHelper::dbFetchValue("\r\n          SELECT count(*) as CNT FROM messages\r\n          WHERE 1=1\r\n            AND guid = :guid", array(':guid' => array($request['guid'], SQLITE3_TEXT)));
     if (!empty($messageExists) || $messageExists > 0) {
         throw new Exception("Message exists");
     }
     // Не надо посылать двойные приглашения
     if ($request['type'] == Api::MESSAGE_TYPE_ADD_FRIEND) {
         $messageExists = DBHelper::dbFetchValue("SELECT count(*) as CNT FROM messages\r\n                WHERE 1=1\r\n                    AND user_from_id = :user_from_id\r\n                    AND reciepent = :reciepent\r\n                    AND type = :type", array(':user_from_id' => array($userId, SQLITE3_INTEGER), ':reciepent' => array($request['reciepent'], SQLITE3_TEXT), ':type' => array(Api::MESSAGE_TYPE_ADD_FRIEND, SQLITE3_INTEGER)));
         // TODO: проверять
         //if (!empty($messageExists) || $messageExists > 0)
         //    throw new Exception("Friend invite already sended");
     }
     DBHelper::dbExec("INSERT INTO messages (user_from_id, type, reciepent, data, guid)\r\n                        VALUES (:user_from_id, :type, :reciepent, :data, :guid)", array(':user_from_id' => array($userId, SQLITE3_INTEGER), ':type' => array($request['type'], SQLITE3_INTEGER), ':reciepent' => array($request['reciepent'], SQLITE3_TEXT), ':guid' => array($request['guid'], SQLITE3_TEXT), ':data' => array($request['data'], SQLITE3_TEXT)));
     // Возвращаем последнее собщение...
     // TODO: Нафига?
     $lastId = DBHelper::dbLastId();
     $messages = DBHelper::dbFetch("SELECT m.*, u.user_name as user_from FROM messages m\r\n            LEFT JOIN users u ON u.user_id = m.user_from_id \r\n            WHERE 1=1 \r\n            AND m.message_id = :last_id", array(':last_id' => array($lastId, SQLITE3_INTEGER)));
     // Дергаем GCM, если есть такая запись
     $gcmToken = DBHelper::dbFetchValue("\r\n          SELECT t.gcm_token FROM tokens t\r\n          LEFT JOIN users u ON t.user_id = u.user_id\r\n          WHERE 1=1\r\n            AND u.user_name = :user_name", array(':user_name' => array($request['reciepent'], SQLITE3_TEXT)));
     if (!empty($gcmToken)) {
         $apiKey = "AIzaSyBtqUk3RimO8igxmCgq6opDqEGckeklFP0";
         $message = $messages[0]["guid"];
         $gcpm = new GCMPushMessage($apiKey);
         $gcpm->setDevices($gcmToken);
         $response = $gcpm->send($message, array('title' => 'Test title'));
         $this->response['gcm'] = $response;
     } else {
         $this->response['gcm'] = "Empty GCM token";
     }
     $this->response['messages'] = $messages;
     $this->response['status'] = 'ok';
 }
コード例 #11
0
ファイル: NotifySend.php プロジェクト: giseoplee/gcm-send
    // echo "<br />";
    //$registration_ids[$arr_cnt] = $rows['registration_key'];
    $registration_ids[] = $rows['registration_key'];
    $next_min = $rows['id'];
    //$arr_cnt++;
}
//print_r($registration_ids);
$next_min += 1;
//$registration_ids = $cDB->Select($query);
//print_r($registration_ids);
$_gcm_api_key = "AIzaSyDa1JpGKQZYNvecZzUe3PEcZ4mQqAKzjv0";
$send_data['no'] = "1";
$send_data['code'] = $notify_data['image_flag'];
$send_data['title'] = $notify_data['title'];
$send_data['msg'] = $notify_data['description'];
$send_data['ticker'] = $notify_data['ticker'];
$send_data['url'] = $notify_data['url'];
// echo count($registration_ids);
// echo "<br /><br /><br /><br />";
$divide_array = array_chunk($registration_ids, MULTICAST_COUNT);
// echo json_encode($send_data);
// echo "<br /><br /><br />";
// echo count($divide_array);
for ($j = 0; $j < count($divide_array); $j++) {
    $gcm = new GCMPushMessage($_gcm_api_key);
    $gcm->setDevices($divide_array[$j]);
    //print_r($gcm);
    $response = $gcm->send($send_data);
    echo $response;
    echo "<br />";
}
コード例 #12
0
<?php

if (isset($_POST["title"]) && isset($_POST["message"])) {
    $title = $_POST["title"];
    $message = $_POST["message"];
    include_once 'GCMPushMessage.php';
    include_once 'db_functions.php';
    include_once 'config.php';
    $gcm = new GCMPushMessage(GOOGLE_API_KEY);
    $db = new DB_Functions();
    $result = $db->getDevices();
    // Notre tableau de token des utilisateurs
    $registatoin_ids = array();
    while ($row = $result->fetch_array()) {
        array_push($registatoin_ids, $row['gcm_token']);
    }
    // listre des utilisateurs à notifier
    $gcm->setDevices($registatoin_ids);
    // Le titre de la notification
    $data['title'] = $title;
    // On notifie nos utilisateurs
    $result = $gcm->send($message, $data);
    echo $result;
}