I have the Message class:
class Mensaje {
public $contenido = "";
public $destino = "";
public $estado = -1;
public $message_id = -1;
function __construct( $destino, $contenido ) {
$this->contenido = $contenido;
$this->destino = $destino;
}
function queue(
$url,
$api_user,
$api_pass,
$api_version
) {
$info = array(
'api_version' => $api_version
'cmd' => 'api_queue_sms',
'content' => $this->contenido,
'destination' => $this->destino,
'password' => $api_pass,
'username' => $api_user,
);
$args = urlencode( json_encode( $info ));
echo $args;
$res = file_get_contents( $url + '?' + $args ).read();
$obj = json_decode( $res );
if ( $obj[ 'success' ] ) {
$mensajes[ $i ].$estado = 0;
$this->message_id = $obj[ 'message_id' ];
echo 'Mensaje insertado exitosamente. Ticket: ' + str( $obj[ 'message_id' ] );
return 1;
} else {
$mensajes[ $i ].$estado = -1;
echo 'Error al insertar mensaje. Codigo de error: ' + $obj[ 'error_code' ];
return -1;
}
}
} //class
I need to concatenate the objects created from this class.
Code where I try to concatenate with append
:
/*** Parte donde quiero concatenar ***/
for ( $c=0; $c < $numero; $c++ ) {
$mensajes->append( new Mensaje( $datos[0], $datos[1] ));
$mensajes[ $i ]->queue( $url, $api_user, $api_pass, $api_version );
$i = $i + 1;
}
Error I get:
> Call to a member function Mensaje() on null in C:\AppServ\www\test_msj_php.php on line 83