Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/05/2016, 09:43
MrEnfurecido
 
Fecha de Ingreso: abril-2016
Mensajes: 15
Antigüedad: 8 años
Puntos: 0
Enviar a multiples usuarios a la vez

Buenas, este es mi codigo para enviar un mensaje a un usuario (el codigo no lo hice yo):

<?php

//Your firebase url
const DEFAULT_URL = 'https://.....com/';

//Checking post request
if($_SERVER['REQUEST_METHOD']=='POST'){

//Connection to database
$con = mysqli_connect('localhost','...','','...');

//Importing firebase libraries
require_once 'firebaseInterface.php';
require_once 'firebaseLib.php';
require_once 'firebaseStub.php';

//Geting email and message from the request

$msg = $_POST['message'];

//Getting the firebase id of the person selected to send notification
$sql = "SELECT * FROM register WHERE email = '$email'";

//Getting the result from database
$res = mysqli_fetch_array(mysqli_query($con,$sql));

//getting the unique id from the result
$uniqueid = $res['firebaseid'];

//creating a firebase variable
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL,'');

//changing the msg of the selected person on firebase with the message we want to send
$firebase->set($uniqueid.'/msg', $msg);

//redirecting back to the sendnotification page
header('Location: sendPushNotification.php?success');


}else{
header('Location: sendPushNotification.php');
}

Si cambio esto:
$sql = "SELECT * FROM register WHERE email = '$email'";

por:

$sql = "SELECT * FROM register;

ya tendria todos los usuarios, pero como hago para que lo haga con todos?...osea que lea el id especifico para cada correo y entonces lo mande...supongo que con un bucle pero...

De php ando muy corto....Gracias...