当前位置: 首页>>代码示例>>PHP>>正文


PHP GCM类代码示例

本文整理汇总了PHP中GCM的典型用法代码示例。如果您正苦于以下问题:PHP GCM类的具体用法?PHP GCM怎么用?PHP GCM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GCM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smartpush

function smartpush($uid, $message)
{
    include "db_functions.php";
    include "gcm.php";
    $gcm = new GCM();
    $db = new DB_Functions();
    $users = $db->getAllUsers();
    if ($users != false) {
        $no_of_users = mysql_num_rows($users);
    } else {
        $no_of_users = 0;
    }
    if ($no_of_users > 0) {
        while ($row = mysql_fetch_array($users)) {
            $regId = $row['gcm_regid'];
            // $message = "สวัสดีชาวโลก";
            $registatoin_ids = array($regId);
            // $message = array("price" => $message);
            $result = $gcm->send_notification($registatoin_ids, $message);
            //echo $result;
        }
    } else {
        echo "ไม่มีข้อมูล";
    }
}
开发者ID:aclub88,项目名称:amss,代码行数:25,代码来源:smartpush.php

示例2: updateRequestStatus

function updateRequestStatus()
{
    $userRequestID = trim($_REQUEST['user_request_id']);
    $requestStatus = trim($_REQUEST['status']);
    $lastInserted_payment_id = 0;
    $rm = new Response_Methods();
    if ($userRequestID == "" || $requestStatus == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        if ($requestStatus == 'Accepted') {
            $fromBankID = $rm->idToValue('payment_from_bank_id', 'user_requests_t', 'user_request_id', $userRequestID);
            $toBankID = $rm->idToValue('payment_to_bank_id', 'user_requests_t', 'user_request_id', $userRequestID);
            $amount = $rm->idToValue('amount', 'user_requests_t', 'user_request_id', $userRequestID);
            $fromBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $fromBankID);
            $toBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $toBankID);
            if ($fromBankBalance < $amount) {
                $result = $rm->insufficient_balance();
                return $result;
            } else {
                if ($fromBankID != $toBankID) {
                    $fromBankBalance = $fromBankBalance - $amount;
                    $toBankBalance = $toBankBalance + $amount;
                }
                $updateFromBankBalance['initial_bank_balance'] = $fromBankBalance;
                $affectedRowsFrom = $rm->update_record($updateFromBankBalance, 'bank_details_t', 'bank_id', $fromBankID);
                $updateToBankBalance['initial_bank_balance'] = $toBankBalance;
                $affectedRowsTo = $rm->update_record($updateToBankBalance, 'bank_details_t', 'bank_id', $toBankID);
                $getInsertFieldValue['amount'] = $amount;
                $getInsertFieldValue['payment_from_bank_id'] = $fromBankID;
                $getInsertFieldValue['payment_to_bank_id'] = $toBankID;
                $getInsertFieldValue['user_request_id'] = $userRequestID;
                $lastInserted_payment_id = $rm->insert_record($getInsertFieldValue, 'payment_details_t');
                $login_user_id = $rm->idToValue('login_user_id', 'user_requests_t', 'user_request_id', $userRequestID);
                $gcm_regid = $rm->getUserGCMREGID($login_user_id);
                if ($gcm_regid != "" || $gcm_regid != "NA") {
                    $gcm = new GCM();
                    $registatoin_ids = array($gcm_regid);
                    $msg = "Request " . $requestStatus;
                    $message = array("Response" => $msg);
                    $resultPush = $gcm->send_notification($registatoin_ids, $message);
                }
                $getRegisterFieldValue['status'] = $requestStatus;
                $affectedRows = $rm->update_record($getRegisterFieldValue, 'user_requests_t', 'user_request_id', $userRequestID);
                if ($affectedRows >= 0) {
                    $result = $rm->requestStatusSuccess($lastInserted_payment_id);
                    return $result;
                } else {
                    $result = $rm->requestStatusFail();
                    return $result;
                }
            }
        }
    }
}
开发者ID:Kavitapsawant,项目名称:Axis-Group,代码行数:55,代码来源:updateRequestStatus.php

示例3: mailing

 function mailing() {
     $gcm = new GCM();
     file_put_contents('mylog.log',"  1----<br>_SEND NOTIFICATION_<br>----  ", FILE_APPEND);
     $result = $dbManager->query("SELECT * FROM `Users` WHERE id IN (SELECT idUser FROM `Сourier`)");
     
     while($row = $dbManager->fetch_assoc($result)) {
         $registatoin_ids = $row['registerId'];
         
         file_put_contents('mylog.log',"  2----<br>_SEND NOTIFICATION_<br>----  ", FILE_APPEND);
         $gcm->send_notification($registatoin_ids, "DEBUG");    
     }
     
             
 }
开发者ID:NG-Studio-Development,项目名称:web-veloportation,代码行数:14,代码来源:index.php

示例4: addUserRequest

function addUserRequest()
{
    //$companyId = $_REQUEST['companyId'];
    $login_user_id = trim($_REQUEST['userID']);
    $fromBankID = trim($_REQUEST['fromBankID']);
    $toBankID = trim($_REQUEST['toBankID']);
    //$paymentDate = trim($_REQUEST['paymentDate']);
    //$paymentReason = trim($_REQUEST['paymentReason']);
    $amount = trim($_REQUEST['amount']);
    $paymentType = trim($_REQUEST['paymentType']);
    $rm = new Response_Methods();
    if ($login_user_id == "" || $fromBankID == "" || $amount == "" || $paymentType == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        $getList = array();
        //inserting payment details
        $getInsertFieldValue['login_user_id'] = $login_user_id;
        $companyID = $rm->idToValue('company_id', 'user_details_t', 'login_user_id', $login_user_id);
        $getInsertFieldValue['payment_from_bank_id'] = $fromBankID;
        $getInsertFieldValue['payment_to_bank_id'] = $toBankID;
        //$getInsertFieldValue['payment_date']=$paymentDate;
        //$getInsertFieldValue['payment_reason']=$paymentReason;
        $getInsertFieldValue['amount'] = $amount;
        $getInsertFieldValue['payment_type'] = $paymentType;
        $getInsertFieldValue['request_created_date'] = $createdDate;
        $getInsertFieldValue['company_id'] = $companyID;
        $lastInserted_user_request_id = $rm->insert_record($getInsertFieldValue, 'user_requests_t');
        if (!empty($lastInserted_user_request_id)) {
            //Do Transactions by updating bank current balance
            /* Sending Push Notification to Admin */
            $gcm_regid = $rm->getUserGCMREGID(2);
            if ($gcm_regid != "" || $gcm_regid != "NA") {
                $gcm = new GCM();
                $registatoin_ids = array($gcm_regid);
                $msg = "User Payment Request Made. Please Check";
                $message = array("Response" => $msg);
                $resultPush = $gcm->send_notification($registatoin_ids, $message);
            }
            $result = $rm->userRequestSuccessJson($lastInserted_user_request_id);
            return $result;
        } else {
            $result = $rm->userRequestFailJson();
            return $result;
        }
    }
}
开发者ID:Kavitapsawant,项目名称:Axis-Group,代码行数:49,代码来源:addUserRequests.php

示例5: mobile_notifications_send

/**
 * Send an Mobile notification
 *
 * @param string $hook   Hook name
 * @param string $type   Hook type
 * @param bool   $result Has anyone sent a message yet?
 * @param array  $params Hook parameters
 * @return bool
 * @access private
 */
function mobile_notifications_send($hook, $type, $result, $params)
{
    // Sender and Recipient Information to get name and username
    $message = $params['notification'];
    $sender = $message->getSender();
    $recipient = $message->getRecipient();
    //Send GCN to Mobile
    include_once elgg_get_plugins_path() . 'web_services/lib/GCM.php';
    $gcm = new GCM();
    $result = $gcm->setup_message($sender->name, $sender->username, $recipient->name, $recipient->username, $message->subject, $message->body);
    if ($result) {
        error_log("Message sent successfully");
    } else {
        error_log("Failed to send message");
    }
}
开发者ID:manlui,项目名称:elgg_with_rest_api,代码行数:26,代码来源:start.php

示例6: gcm_register

/**
 * Created by PhpStorm.
 * Date: 12/7/2015
 * Time: 12:30 PM
 * @param $regId
 * @param $account
 * @param $name
 * @return mixed
 * @throws InvalidParameterException
 */
function gcm_register($regId, $account, $name)
{
    if (!$account) {
        $response['status'] = 1;
        $response['result'] = 'please enter valid user account';
        return $response;
        exit;
    } else {
        $user = get_user_by_username($account);
        if (!$user) {
            throw new InvalidParameterException('registration:usernamenotvalid');
            $response['status'] = 1;
            $response['result'] = 'user account not valid';
            return $response;
            exit;
        }
    }
    // create the tables for API stats
    $path = elgg_get_plugins_path();
    run_sql_script($path . "elgg_with_rest_api/schema/mysql.sql");
    if ($account && $regId) {
        $elgg_post = 1;
        $elgg_message = 1;
        // Store user details in db
        include_once $path . 'elgg_with_rest_api/lib/DB_Register_Functions.php';
        include_once $path . 'elgg_with_rest_api/lib/GCM.php';
        $db = new DB_Register_Functions();
        $gcm = new GCM();
        if ($db->checkUser($regId)) {
            $res = $db->updateUser($name, $account, $regId, $elgg_post, $elgg_message);
            $response['status'] = 0;
            $response['result'] = "success update gcm regId and user info";
        } else {
            $res = $db->storeUser($name, $account, $regId, $elgg_post, $elgg_message);
            $registration_ids = array($regId);
            $message = array("from_name" => "Core Server", "subject" => "Core App Notification", "message" => "Enable Receive Notification");
            $result = $gcm->send_notification($registration_ids, $message);
            $response['status'] = 0;
            $response['result'] = "success Insert gcm regId and user info";
        }
    } else {
        // user details missing
        $response['status'] = 1;
        $response['result'] = 'Missing name or reg id';
    }
    return $response;
}
开发者ID:rohit1290,项目名称:elgg_with_rest_api,代码行数:57,代码来源:gcm_register.php

示例7: send_notification

function send_notification($status, $id)
{
    global $db;
    $gcm = new GCM();
    if ($status == 0 || $status == "0") {
        $query = "SELECT * FROM login,family WHERE member_id = '{$id}' AND id = family_id ";
        $result = $db->query_db($query);
        if ($db->number_of_rows($result) > 0) {
            while ($row = $db->fetch_array($result)) {
                $regId = $row["gcm_regId"];
                $message = " is in danger";
                $registatoin_ids = array($regId);
                $message = array("message" => $message, "id" => $id);
                $notification_result = $gcm->send_notification($registatoin_ids, $message);
            }
        } else {
            // no family members are found
        }
    }
}
开发者ID:navneet1v,项目名称:Disaster-Safety,代码行数:20,代码来源:change_status.php

示例8: sendNotification

 public function sendNotification($message_id, $message, $users)
 {
     $this->init();
     try {
         foreach ($users as $user) {
             $user_id = $user->id;
             $registatoin_ids = array($user->gcm_regid);
             $json = GCM::get()->send_notification($registatoin_ids, $message);
             if (!$json) {
                 return -400;
                 //Curl failed
             }
             $ret = json_decode($json, true);
             if ($ret['success']) {
                 $state = 1;
                 //success
                 $this->success_count++;
                 $state_text = $ret['results'][0]['message_id'];
             } elseif ($ret['failure']) {
                 $state = 2;
                 //failed
                 $this->fail_count++;
                 $state_text = $ret['results'][0]['error'];
             } else {
                 $state = 2;
                 //failed
                 $this->fail_count++;
                 $state_text = strpos($json, 'Unauthorized') ? 'Unauthorized API key' : 'Undefined';
             }
             //                $state_text = isset($ret['results'][0]['error']) ? $ret['results'][0]['error'] : $ret['results'][0]['message_id'];
             $message_state = new MessageState();
             $message_state->message_id = $message_id;
             $message_state->user_id = $user_id;
             $message_state->state = $state;
             $message_state->state_text = $state_text;
             $message_state->save();
         }
         return 101;
     } catch (Exception $e) {
         return -100;
     }
 }
开发者ID:Hounge,项目名称:Android_Push_Server,代码行数:42,代码来源:Notification.php

示例9: GCM

<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if (isset($_GET["regId"]) && isset($_GET["message"])) {
    $regId = $_GET["regId"];
    $message = $_GET["message"];
    include_once './GCM.php';
    $gcm = new GCM();
    $registation_ids = array($regId);
    $message = array("price" => $message);
    $result = $gcm->send_notification($registation_ids, $message);
    echo $result;
}
开发者ID:rbaltodanog,项目名称:audinsaapp,代码行数:16,代码来源:send_message.php

示例10: distribusiSurat

function distribusiSurat($db, $token, $id_surat, $subject, $tu, $tembusan, $nama_institusi)
{
    $tujuan = explode("@+id/", $tu);
    // explode dulu tujuannya
    $registration_ids = array();
    for ($i = 0; $i < count($tujuan); $i++) {
        if (!empty($tujuan[$i])) {
            //            echo $id_surat . " - " . $tujuan[$i] . " - " . $tembusan . " <br/>";
            kirimSurat($db, $id_surat, $tujuan[$i], $tembusan);
            if (!empty(pushNotification($db, $tujuan[$i]))) {
                $registration_ids = pushNotification($db, $tujuan[$i]);
            }
        }
    }
    if (count($registration_ids) > 0) {
        $gcm = new GCM();
        $pesan = array("message" => $subject, "title" => "Surat baru dari {$nama_institusi}", "msgcnt" => 1, "sound" => "beep.wav");
        $result = $gcm->send_notification($registration_ids, $pesan);
    } else {
        $result = '"Not a GCM User"';
    }
    echo '{"isUnreads": ' . countUnreads($token) . ', "isFavorites": ' . countFavorites($token) . ', "isUnsigned": ' . countUnsigned($token) . ', "result": ' . $result . '}';
    //    echo $result;
}
开发者ID:agungsb,项目名称:notifion-api,代码行数:24,代码来源:index.php

示例11: session_start

<?php

require_once "../../../config.php";
require_once "../../../dist/class/class.connect.php";
require_once "../../../dist/functions/data.access.php";
$c_host = $databaselocation;
$c_user = $databaseuser;
$c_pass = $databasepass;
$c_db = $databasename;
session_start();
if (!isset($_SESSION["loged"])) {
    $html = file_get_contents("../../session_error.html");
    $html;
} else {
    $message = $_GET["message"];
    $gcm_regs = getGCMRegs();
    include_once './GCM.php';
    $gcm = new GCM();
    foreach ($gcm_regs as $regs) {
        $result = $gcm->send_notification($regs->reg_id, $message);
    }
    $result = TRUE;
    echo $result;
}
开发者ID:sebastian-aranda,项目名称:helpycar-webpage,代码行数:24,代码来源:send_notification_action.php

示例12: join

$select_sql[] = " order by regdate desc ";
$select_sql[] = " limit 1;";
$sql = join("", $select_sql);
$query1 = mysql_query($sql);
$registration_ids = array();
while ($list = mysql_fetch_assoc($query1)) {
    $registration_ids[] = $list['token_id'];
}
//print_r($registration_ids);
//$message = array();
/*선행 조건 2016-03-08 (화)
여태까지 보낸 로그를 카운트 모바일에서 보낸 것을 합산 하여서 제한 갯수를 초과한 경우 보내지 않도록 설계

*/
include_once "./GCM.php";
$gcm = new GCM();
/* 자동 전송 crontab linux scheduler */
if ($mode == "crontab") {
    $messages = array("title" => $title, "message" => $message, "is_mms" => $is_mms, "receiver_num" => $receiver_num, "img_url" => $img_url);
    /*prq_gcm_log 발생*/
    //echo  $gcm->send_notification($registration_ids, $message);
    $push = json_decode($gcm->send_notification($registration_ids, $messages));
    $p_temp = $push->results[0]->message_id;
    $result = strpos($p_temp, "0:") !== false ? true : false;
    $result_msg = $result ? "전달 성공" : "전송 실패";
    $gc_ipaddr = '123.142.52.91';
    $sql = array();
    $sql[] = "INSERT INTO `prq_gcm_log` SET ";
    $sql[] = "gc_subject='" . $title . "',";
    $sql[] = "gc_content='" . $message . "',";
    $sql[] = "gc_ismms='" . $is_mms . "',";
开发者ID:Taebu,项目名称:prq,代码行数:31,代码来源:set_gcm.php

示例13: GCM

<?php

if (isset($_GET["regId"]) && isset($_GET["message"])) {
    $regId = $_GET["regId"];
    $message = $_GET["message"];
    include_once './GCM.php';
    $gcm = new GCM();
    $registrationIds = [$regId];
    $message = ["price" => $message];
    $result = $gcm->send_notification($registrationIds, $message);
    echo $result;
}
开发者ID:RickyCruz,项目名称:Curso-Datafit-Android-Notificaciones-Push,代码行数:12,代码来源:send_message.php

示例14: unset

     unset($a->meta_values);
     //echo '<pre>'; print_r($a); echo '</pre>';
     return $a;
 }
 $businesses = array_map('massage', $businesses);
 // Get all devices registration IDs
 foreach ($businesses as $business) {
     if ($business->meta['os_type'] == 'android' && $business->meta['business_id'] == $postid) {
         $android_devices[] = $business->meta['registration_id'];
     } elseif ($business->meta['os_type'] == 'ios' && $business->meta['business_id'] == $postid) {
         $ios_devices[] = $business->meta['registration_id'];
     }
 }
 // Send Push notification to Android devices
 if (count($android_devices) > 0) {
     $gcm = new GCM();
     $msg_body = $coupon_biz_name . ': Use coupon code ' . $_POST['coupon_code'] . ' to avail ' . $_POST['coupon_desc'] . ' on ' . $_POST['coupon_start_date'] . ' to  ' . $_POST['coupon_end_date'];
     $message = array('message' => $msg_body);
     $result = $gcm->send_notification($android_devices, $message);
 }
 // Send Push notification to iOS
 if (count($ios_devices) > 0) {
     $message = $coupon_biz_name . ': Use coupon code ' . $_POST['coupon_code'] . ' to avail ' . $_POST['coupon_desc'] . ' on ' . $_POST['coupon_start_date'] . ' to  ' . $_POST['coupon_end_date'];
     $ctx = stream_context_create();
     stream_context_set_option($ctx, 'ssl', 'local_cert', 'Vintelli.pem');
     stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
     stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer');
     // Open a connection to the APNS server
     // ssl://gateway.sandbox.push.apple.com:2195
     // ssl://gateway.push.apple.com:2195
     $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
开发者ID:biswajit-paul,项目名称:gittest,代码行数:31,代码来源:save_business-01-10-2015.php

示例15: send_android_push

function send_android_push($user_id, $message, $title)
{
    require_once 'gcm/GCM_1.php';
    /* require_once 'gcm/const.php'; */
    if (!isset($user_id) || empty($user_id)) {
        $registatoin_ids = "0";
    } else {
        $registatoin_ids = trim($user_id);
    }
    if (!isset($message) || empty($message)) {
        $msg = "Message not set";
    } else {
        $msg = trim($message);
    }
    if (!isset($title) || empty($title)) {
        $title1 = "Message not set";
    } else {
        $title1 = trim($title);
    }
    /* $message = array(TEAM => $title1, MESSAGE => $msg); */
    $message = array('team' => $title1, 'message' => $msg);
    $gcm = new GCM();
    $registatoin_ids = array($registatoin_ids);
    $gcm->send_notification($registatoin_ids, $message);
}
开发者ID:felipemarques8,项目名称:goentregas,代码行数:25,代码来源:helper.php


注:本文中的GCM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。