推送通知在php中无效

时间:2015-02-25 12:13:42

标签: php

我尝试在解决用户查询后向移动设备发送推送通知,但它无效。这是我的代码任何问题,它是说如下错误:

  

注意:未定义的变量,path / solvequery.php中的resultRequest行号:15

     

警告:无法在路径/ solvequery.php第47行修改已经发送的头信息头(在resolvequery.php第15行开始输出)...

     

注意:未定义的变量,path / solvequery.php中的resultRequest行号:15

     

警告:无法在path / solvequery.php第47行修改已经发送的标题信息标题(在resolvequery.php第15行开始输出)

     

注意:未定义的变量,path / solvequery.php中的resultRequest行号:15

     

警告:无法在path / solvequery.php第47行修改已经发送的标题信息标题(在resolvequery.php第15行开始输出)

solvequery.php:

       <?php
        include_once 'config.php';
        $id='';
        if(isset($_REQUEST['id_query']))
            $id = $_REQUEST['id_query'];
        if(isset($_REQUEST['requesttype'])&&$_REQUEST['requesttype']=='solve'){
            if(isset($_REQUEST['solve'])&&$_REQUEST['solve']=='solve')
            {
                $updateInfo['status']='Resolved';
                $date=date('Y-m-d H:i:s');
                $updateInfo['date_updated']=$date;
                $updateCondition=" id_query='".$id."'";
                $trueFalse=$db->update('query',$updateInfo,$updateCondition);


         $id=$resultRequest[0]['users_id_user'];
            $where="t.users_id_user='$id' AND";
            $query="SELECT t.device_id,t.platforms_id_platform as id_platform FROM tokens as t WHERE $where t.device_id!=''";
            $resultTokens=$db->select($query);
                if($resultTokens)
            {
                include_once 'Gcm.php';
                include_once 'Apns.php';
                $deviceTokens=array();
                $deviceTokens1=array();
                $alert='Your Query Solved';
                foreach($resultTokens as $token)
                {
                    if($token['id_platform']=='1'&&$token['device_id']!='')
                        $deviceTokens[]=$token['device_id'];
                    if($token['id_platform']=='2'&&$token['device_id']!='')
                        $deviceTokens1[]=$token['device_id'];
                }
                if(count($deviceTokens)>0)
                {
                    $apns=new Apns();
                    $apns->apnsPush($deviceTokens,$alert);
                }
                if(count($deviceTokens1)>0)
                {
                    $gcm = new GCM();
                    $message = array("m" => $alert);
                    $result = $gcm->send_notification($deviceTokens1,$message);
                }
            }



            }
            header("Location: query.php");
        }
        $query="SELECT u.name,u.email,u.phone,q.id_query,q.subject,q.status as reqstatus,q.description,q.date_created FROM users as u,query as q WHERE q.id_query='$id' AND q.users_id_user=u.id_user";
        $resultRequest=$db->select($query);

        foreach($resultRequest as $request)
        {
        ?>
        <div class="wrapper" style="width:380px;">
                <div class="fluid">
            <form name="frmRequest" action="solveQuery.php" method="POST">
                <div class="formRow">
                    <div class="grid3"><label>Name:</label></div>
                    <div class="grid9 check"><?php echo $request['name']?></div>
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <div class="grid3"><label>Subject:</label></div>
                    <div class="grid9 check"><?php echo $request['subject']?></div>
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <div class="grid3"><label>Query:</label></div>
                    <div class="grid9 check"><?php echo $request['description']?></div>
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <div class="grid3"><label>Status:</label></div>
                    <div class="grid9 check"><?php echo $request['reqstatus']?></div>
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <div class="grid3"><label>Queried on:</label></div>
                    <div class="grid9 check"><?php echo date('d-m-Y H:i:s', strtotime($request['date_created']))?></div>
                    <div class="clear"></div>
                </div>
                <?php if($request['reqstatus']!='Resolved'){?>
                <div class="formRow">
                    <div class="grid3"><label>Solve:</label></div>
                    <div class="grid9 check"><input style="margin-top:5px;" type="checkbox" id="solve"  name="solve" value="solve" /></div>
                    <div class="clear"></div>
                </div>        
                <input type="hidden" value="<?php echo $id?>" name="id_query">
                <input type="hidden" value="solve" name="requesttype">
                <div class="formRow">
                    <div class="status" id="status1"></div>
                    <div class="formSubmit">

                        <input class="buttonM bGreen" id="next1" value="Submit" type="submit"/>
                        <div class="clear"></div>
                    </div>   
                    <div class="clear"></div>
                </div>
                <?php }?>
            </form>
        </div>
        </div>
        <?php
           }
        ?>

1 个答案:

答案 0 :(得分:0)

您应首先解决此问题:

Notice:Undefined variable,resultRequest in path/solvequery.php line no:15

您访问变量$resultRequest但未事先定义它。当此错误不再显示时,您的第二个问题也应该消失。