本文整理汇总了PHP中Pusher::presence_auth方法的典型用法代码示例。如果您正苦于以下问题:PHP Pusher::presence_auth方法的具体用法?PHP Pusher::presence_auth怎么用?PHP Pusher::presence_auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pusher
的用法示例。
在下文中一共展示了Pusher::presence_auth方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validAuthenticationResponse
/**
* Return the valid authentication response.
*
* @param \Illuminate\Http\Request $request
* @param mixed $result
* @return mixed
*/
public function validAuthenticationResponse($request, $result)
{
if (Str::startsWith($request->channel_name, 'private')) {
return $this->decodePusherResponse($this->pusher->socket_auth($request->channel_name, $request->socket_id));
} else {
return $this->decodePusherResponse($this->pusher->presence_auth($request->channel_name, $request->socket_id, $request->user()->id, $result));
}
}
示例2: join
/**
* {@inheritdoc}
*/
public function join(string $channel, array $data = [])
{
Assertion::notEmptyKey($data, 'socketId', "Invalid socket id");
Assertion::notEmptyKey($data, 'userId', "Invalid user id");
Assertion::notEmptyKey($data, 'fullName', "Invalid full name");
return $this->pusher->presence_auth($channel, $data['socketId'], $data['userId'], ['id' => $data['userId'], 'name' => utf8_encode($data['fullName'])]);
}
示例3: Pusher
<?php
require 'Pusher.php';
// you get your own app key, secret and id, by creating an account at pusher.com
$pusher = new Pusher(APP_KEY, APP_SECRET, APP_ID);
$user_id = rand(1, 4000);
$user_info = array('name' => $_GET["your_name"]);
echo $pusher->presence_auth($_POST['channel_name'], $_POST['socket_id'], $user_id, $user_info);
示例4: getenv
require '../_includes/config.php';
$appId = getenv('PUSHER_APP_ID');
$appKey = getenv('PUSHER_APP_KEY');
$appSecret = getenv('PUSHER_APP_SECRET');
$pusher = new Pusher($appKey, $appSecret, $appId);
/*
Uncomment this to have internal Pusher PHP library logging
information echoed in the response to the incoming request
*/
// class EchoLogger {
// public function log($msg) {
// echo($msg);
// }
// }
//
// $pusher->set_logger(new EchoLogger());
$channelName = $_POST['channel_name'];
$socketId = $_POST['socket_id'];
/*
TODO: implement checks to determine if the user is:
1. Authenticated with the app
2. Allowed to subscribe to the $channelName
3. Sanitize any additional data that has been recieved and is to be used
If so, proceed...
*/
$userId = uniqid('user_');
$userInfo = ['website' => 'http://www.leggetter.co.uk', 'company' => 'Pusher', 'job_title' => 'Head of Developer Relations', 'is_active' => true, 'email' => 'phil@pusher.com'];
$auth = $pusher->presence_auth($channelName, $socketId, $userId, $userInfo);
header('Content-Type: application/json');
echo $auth;
示例5: Pusher
<?php
require_once 'Config.php';
require_once 'Pusher.php';
/************************************
* Super dumb Pusher auth (;_;) *
************************************/
if (!empty($_COOKIE['chat-username']) && !empty($_COOKIE['chat-email']) && !empty($_POST['channel_name']) && !empty($_POST['socket_id'])) {
$pusher = new Pusher(APP_KEY, APP_SECRET, APP_ID);
$username = mb_substr(htmlspecialchars($_COOKIE['chat-username']), 0, 30);
$email = htmlspecialchars($_COOKIE['chat-email']);
$channel_name = $_POST['channel_name'];
$socket_id = $_POST['socket_id'];
echo $pusher->presence_auth($channel_name, $socket_id, $username, array('username' => $username, 'email' => $email));
} else {
die('Invalid request');
}
示例6: function
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('index');
});
Route::post('pusher/auth', function (Illuminate\Http\Request $request) {
$pusher = new Pusher(config('broadcasting.connections.pusher.key'), config('broadcasting.connections.pusher.secret'), config('broadcasting.connections.pusher.app_id'));
return $pusher->presence_auth($request->input('channel_name'), $request->input('socket_id'), uniqid(), ['username' => $request->input('username')]);
});
Route::resource('messages', 'Message', ['only' => ['index', 'store']]);
示例7: Pusher
<?php
require_once '../../config.class.php';
require_once '../Pusher.php';
require_once '../pusher_defaults.php';
$pusher = new Pusher(Config::pusher_key, Config::pusher_secret, Config::pusher_app_id, true);
$channel = isset($_REQUEST['channel_name']) ? $_REQUEST['channel_name'] : $presence_default_channel;
$socket_id = $_REQUEST['socket_id'];
$user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : time();
$_SESSION['user_id'] = $user_id;
$user_name = isset($_REQUEST['user_name']) ? $_REQUEST['user_name'] : 'valued_user';
echo $pusher->presence_auth($channel, $socket_id, $user_id, array('name' => $user_name));
示例8: crearConexion
//Autenticar
require_once './vendor/autoload.php';
session_start();
include "_db.php";
$con = crearConexion();
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}
$app_id = '163546';
$app_key = '1af1d4c26abef175083a';
$app_secret = 'b06bd7deadbe3c59cd79';
$pusher = new Pusher($app_key, $app_secret, $app_id, array('encrypted' => true));
if (!isset($_POST['sala'], $_POST['password'])) {
echo "Ingrese una contraseña por favor";
} else {
$sala = $_POST['sala'];
$password = $_POST['password'] || "";
$stmt = $con->prepare("SELECT passsala,COUNT(*) as existe FROM salas WHERE nombre = ?");
$stmt->bind_param("s", $sala);
$stmt->execute();
$stmt->bind_result($col1, $col2);
while ($stmt->fetch()) {
if ($col1 == $password || empty($col1) || $col2 < 1) {
$data = array('admin' => $_POST['admin']);
echo $pusher->presence_auth($_POST['channel_name'], $_POST['socket_id'], $_POST['sala'] . "-" . $_POST['socket_id'], $data);
} else {
echo "false";
}
}
$stmt->close();
}
示例9: Pusher
<?php
/* ------------ user autentification ---------------
/*
* Pusher chat
* facebook like chat jQuery plugin using Pusher API
* version: 1.0
* Author & support : zied.hosni.mail@gmail.com
* © 2012 html5-ninja.com
* for more info please visit http://html5-ninja.com
*
*/
require_once 'config.php';
// https://github.com/squeeks/Pusher-PHP
require_once '../lib/Pusher.php';
$name = $_GET['name'];
// chose the way to get this get,post session ...etc
$user_id = $_GET['user_id'];
// chose the way to get this get,post session ...etc
$channel_name = $_POST['channel_name'];
// never change
$socket_id = $_POST['socket_id'];
// never change
$pusher = new Pusher($key, $secret, $app_id);
$presence_data = array('name' => $name);
echo $pusher->presence_auth($channel_name, $socket_id, $user_id, $presence_data);
示例10: Pusher
<?php
include "pusher.php";
$pusher = new Pusher("9f2cde4bf9c16af5d034", "bf441c57e38a97b090b1", "90168");
$presence_data = array('username' => "miamiam", 'avatar' => "lolol");
echo $pusher->presence_auth($_POST['channel_name'], $_POST['socket_id'], rand(1, 200), $presence_data);
示例11: Pusher
<?php
require_once 'Pusher.php';
// Define constants for the pusher api info
define('PUSHER_API_KEY', 'YOUR KEY');
define('PUSHER_API_SECRET', 'YOUR SECRET');
define('PUSHER_APP_ID', 'YOUR APP ID');
// Creating a connection to Pusher
$pusher = new Pusher(PUSHER_API_KEY, PUSHER_API_SECRET, PUSHER_APP_ID);
$uniqid = uniqid();
$presence_data = array('id' => $uniqid);
$auth = $pusher->presence_auth($_GET['channel_name'], $_GET['socket_id'], $uniqid, $presence_data);
$callback = str_replace('\\', '', $_GET['callback']);
header('Content-Type: application/javascript');
echo $callback . '(' . $auth . ');';
示例12: Process
public function Process()
{
$this->cachedir = JPATH_ROOT . "/cache/" . get_class($this);
file_exists($this->cachedir) or mkdir($this->cachedir);
//$this->CacheLifetime = intval($this->Params->get("cache_lifetime", 2)) * 60; // Converte da minuti in secondi
$this->CacheLifetime = 2 * 60;
// Converte da minuti in secondi 2 minuti
$tw_consumer_key = trim($this->Params->get("twitter_consumer_key", ""));
$tw_consumer_secret = trim($this->Params->get("twitter_consumer_secret", ""));
$app_id = trim($this->Params->get("pusher_app_id", ""));
$app_key = trim($this->Params->get("pusher_app_key", ""));
$app_secret = trim($this->Params->get("pusher_app_secret", ""));
/*
if (isset($_POST['channel_name']) && isset($_POST['socket_id']) && isset($_POST['only_get_num']) && $_POST['only_get_num']){
$verify_channel=$_POST['channel_name'];//private- presence-
$verify_socketid=$_POST['socket_id'];
$parts=explode('-',$verify_channel);
$channel_type=$parts[0];
if ($channel_type == 'presence'){
$pusher = new Pusher($app_key, $app_secret, $app_id);
$presence_data = array(
'displayName' => 'hidden',
'objectType' => 'person',
'image' => array('url'=>''),
'userid'=>'hidden-hidden',
'link'=>''
);
echo $pusher->presence_auth($verify_channel, $verify_socketid, $presence_data['userid'], $presence_data);
JFactory::getApplication()->close();
}
}
*/
if (isset($_POST['only_get_num']) && $_POST['only_get_num']) {
if (!isset($_POST['channel_name'])) {
$this->returnError("Invalid channel");
}
$verify_channel = $_POST['channel_name'];
//private- presence-
$parts = explode('-', $verify_channel);
$channel_type = $parts[0];
if ($channel_type == 'presence') {
//Caching! QUi
$cache_expired = true;
$num_users_connected = 0;
$cachefile = $this->cachedir . "/" . $this->getHash(array($app_key, $verify_channel), array($app_secret, $app_id));
if (file_exists($cachefile)) {
$age = time() - filemtime($cachefile);
$lt = $this->CacheLifetime;
if ($age < $lt) {
$num_users_connected = file_get_contents($cachefile);
$cache_expired = false;
}
}
if ($cache_expired) {
$pusher = new Pusher($app_key, $app_secret, $app_id);
//echo json_encode($pusher->get('/channels/'.$verify_channel.'/members'));
$users = $pusher->get('/channels/' . $verify_channel . '/users');
$users = json_decode($users['body'], true);
$num_users_connected = count($users['users']);
file_put_contents($cachefile, $num_users_connected);
}
//error_log(var_export($users,true)."\n",3,'C:\workspace\php-errors.log');
echo json_encode(array('c' => $num_users_connected));
JFactory::getApplication()->close();
} else {
$this->returnError("Invalid channel");
}
}
$anonymous_login = intval($this->Params->get("anonymous_login", "1")) == 1;
$joomla_login = intval($this->Params->get("joomla_login", "1")) == 1;
$facebook_login = false;
$googleplus_login = false;
$twitter_login = false;
$fb_app_id = trim($this->Params->get("facebook_app_id", ""));
$fb_app_secret = trim($this->Params->get("facebook_app_secret", ""));
if (!empty($fb_app_id) && !empty($fb_app_secret)) {
$facebook_login = true;
}
$gp_client_id = trim($this->Params->get("googleplus_client_id", ""));
$gp_client_secret = trim($this->Params->get("googleplus_client_secret", ""));
if (!empty($gp_client_id) && !empty($gp_client_secret)) {
$googleplus_login = true;
}
if (!empty($tw_consumer_key) && !empty($tw_consumer_secret)) {
$twitter_login = true;
}
$available_logins = array();
if ($anonymous_login) {
$available_logins[] = 'anonymous';
}
if ($joomla_login) {
$available_logins[] = 'joomla';
}
if ($facebook_login) {
$available_logins[] = 'facebook';
//.........这里部分代码省略.........
示例13: Pusher
<?php
require_once 'smswall.inc.php';
require 'libs/Pusher.php';
$pusher = new Pusher(PUSHER_KEY, PUSHER_SECRET, PUSHER_APPID);
$presence_data = array('name' => 'publicwall');
$uid = uniqid();
echo $pusher->presence_auth($_POST['channel_name'], $_POST['socket_id'], $uid, $presence_data);