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


PHP Pusher::socket_auth方法代码示例

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


在下文中一共展示了Pusher::socket_auth方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
     }
 }
开发者ID:hannesvdvreken,项目名称:framework,代码行数:15,代码来源:PusherBroadcaster.php

示例2: trim

<?php

// include Pusher PHP library
require_once 'lib/Pusher.php';
// Replace with auth information for your app
$auth_key = "";
$secret_key = "";
$app_id = "";
// read channel name and socket id from request
$channel_name = trim($_REQUEST['channel_name']);
$socket_id = trim($_REQUEST['socket_id']);
// use Pusher PHP library to generate auth signature and echo as response to client
$pusher = new Pusher($auth_key, $secret_key, $app_id);
$auth_sig = $pusher->socket_auth($channel_name, $socket_id);
echo $auth_sig;
开发者ID:jordanranson-archive,项目名称:pusher-dotnet-unity-client,代码行数:15,代码来源:pusher-auth.php

示例3: getenv

require '../../vendor/autoload.php';
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...
*/
$auth = $pusher->socket_auth($channelName, $socketId);
header('Content-Type: application/json');
echo $auth;
开发者ID:pborreli,项目名称:gs-pusher-php-no-framework,代码行数:30,代码来源:server.php

示例4: Pusher

<?php

require 'Pusher.php';
$app_id = '142419';
$app_key = '875a535db554ca357be9';
$app_secret = 'd97dd660cfe8f4e8a900';
$pusher = new Pusher($app_key, $app_secret, $app_id);
list(, $userId) = explode('.', $_POST['socket_id']);
$auth = $pusher->socket_auth($_POST['channel_name'], $userId);
//$presence_data = array('user_id' => $userId);
$presence_data = array();
echo $pusher->presence_auth($_POST['channel_name'], $_POST['socket_id'], $userId, $presence_data);
开发者ID:kgalanty,项目名称:ships_statki,代码行数:12,代码来源:pusher_auth.php

示例5: pusherAuth

 /**
  * @param Request $request
  * @return string
  * @throws AuthenticationException
  */
 public function pusherAuth(Request $request)
 {
     //Verify the user has permission to connect to the chosen channel
     if ($request->get('channel_name') !== 'private-' . Auth::id()) {
         throw new AuthenticationException();
     }
     $pusher = new \Pusher(config('broadcasting.connections.pusher.key'), config('broadcasting.connections.pusher.secret'), config('broadcasting.connections.pusher.app_id'));
     return $pusher->socket_auth($request->get('channel_name'), $request->get('socket_id'));
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:14,代码来源:SessionController.php

示例6: __construct

 public function __construct()
 {
     define('WP_USE_THEMES', false);
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php';
     $this->options = get_option('wp_pusher', false);
     if ($this->options !== false && $this->options['key'] !== '' && $this->options['secret'] !== '' && $this->options['app_id'] !== '') {
         include_once 'pusher-php-server/lib/Pusher.php';
         $pusher = new Pusher($this->options['key'], $this->options['secret'], $this->options['app_id']);
         echo $pusher->socket_auth($_POST['channel_name'], $_POST['socket_id']);
     }
 }
开发者ID:sternt,项目名称:WP-Pusher,代码行数:11,代码来源:wp-pusher-auth.php

示例7: Pusher

<?php

require __DIR__ . '/vendor/autoload.php';
$app_id = '134441';
$app_key = '599cb5ed77cd5efb659a';
$app_secret = '76a57ea82e311bcbbb1f';
error_log('post ' . var_export($_SERVER, true));
$channel_name = $_POST['channel_name'];
$socket_id = $_POST['socket_id'];
error_log($app_id);
error_log($app_key);
error_log($app_secret);
error_log('channel name: ' . $channel_name);
error_log('socket id: ' . $socket_id);
$pusher = new Pusher($app_key, $app_secret, $app_id);
echo $pusher->socket_auth($channel_name, $socket_id);
开发者ID:schemon,项目名称:PusherAuthEndpointPHP,代码行数:16,代码来源:index.php

示例8: Pusher

<?php

use app\config\Config;
// Initialize the app
require_once '../../app/init.php';
// Include the pusher library
require_once '../../lib/pusher/Pusher.php';
// Gather the pusher key, secret and application ID
$authKey = Config::getValue('pusher', 'auth_key', '');
$secret = Config::getValue('pusher', 'secret', '');
$appId = Config::getValue('pusher', 'app_id', '0');
// Create a pusher instance with the proper key, secret and application ID
$pusher = new Pusher($authKey, $secret, $appId);
// Authenticate the request
echo $pusher->socket_auth($_POST['channel_name'], $_POST['socket_id']);
开发者ID:timvisee,项目名称:MohicanenPieGuesser,代码行数:15,代码来源:auth.php

示例9: Process


//.........这里部分代码省略.........
     if (!empty($oc_logged_in) && in_array($oc_logged_in, $available_logins)) {
         $session_var_name = 'oc_user_id_' . $oc_logged_in;
         if (isset($_COOKIE[$session_var_name]) && $session->has($session_var_name)) {
             $actor = $session->get($session_var_name);
             if ($actor['userid'] == $_COOKIE[$session_var_name]) {
                 $this->logged_in = true;
                 $this->actor = $actor;
             }
         }
         if (!$this->logged_in) {
             if ($oc_logged_in == 'googleplus') {
                 $this->googleplusLogin();
             } else {
                 if ($oc_logged_in == 'facebook') {
                     $this->facebookLogin();
                 } else {
                     if ($oc_logged_in == 'joomla') {
                         $this->joomlaLogin();
                     } else {
                         if ($oc_logged_in == 'twitter') {
                             $this->twitterLogin();
                         } else {
                             if ($oc_logged_in == 'anonymous') {
                                 $this->anonymousLogin($_COOKIE['oc_anon_name'], $_COOKIE['oc_anon_email']);
                             }
                         }
                     }
                 }
             }
             if ($this->logged_in) {
                 $session->set($session_var_name, $this->actor);
             }
         }
     }
     if (isset($_POST['loginonly'])) {
         if ($this->logged_in) {
             header('Cache-Control: no-cache, must-revalidate');
             header('Content-type: application/json');
             echo json_encode(array('OK'));
             //die();
             JFactory::getApplication()->close();
             return;
         } else {
             $this->returnError("Not logged in");
         }
     }
     if (isset($_POST['channel_name']) && isset($_POST['socket_id'])) {
         //authendpoint private or presence
         $verify_channel = $_POST['channel_name'];
         //private- presence-
         $verify_socketid = $_POST['socket_id'];
         $parts = explode('-', $verify_channel);
         $channel_type = $parts[0];
         if (!in_array($channel_type, array('private', 'presence'))) {
             $this->returnError('invalid private or presence channel');
         }
         if ($this->logged_in) {
             $pusher = new Pusher($app_key, $app_secret, $app_id);
             $presence_data = $this->actor;
             if ($channel_type == 'presence') {
                 echo $pusher->presence_auth($verify_channel, $verify_socketid, $this->actor['userid'], $presence_data);
             } else {
                 echo $pusher->socket_auth($verify_channel, $verify_socketid);
             }
             JFactory::getApplication()->close();
         } else {
             $this->returnError("Forbidden");
         }
         return;
     }
     if (isset($_POST['chat_info'])) {
         //send message
         $channel_name = "private-" . $this->get_channel_name($this->Params->get("pusher_channel_name", "channel1"));
         $result = array();
         //'activity' => $data, 'pusherResponse' => $response);
         //if (isset($_POST['chat_info']['logout']) && isset($_POST['chat_info']['logout']['logout_from'])){
         //non devo fare nulla
         //	$this->logged_in=false;
         //}
         if ($this->logged_in && isset($_POST['chat_info']['text']) && !empty($_POST['chat_info']['text'])) {
             //creo il messaggio
             date_default_timezone_set('UTC');
             $data = array('id' => uniqid(), 'body' => mb_substr($_POST['chat_info']['text'], 0, 300), 'published' => date('r'), 'type' => 'chat-message', 'actor' => $this->actor);
             $data['actor']['displayName'] = mb_substr($data['actor']['displayName'], 0, 30);
             //invio del messaggio
             $pusher = new Pusher($app_key, $app_secret, $app_id);
             $response = $pusher->trigger($channel_name, 'chat_message', $data);
             $result = array('activity' => $data, 'pusherResponse' => $response);
         }
         //output result
         header('Cache-Control: no-cache, must-revalidate');
         header('Content-type: application/json');
         echo json_encode($result);
         //die();
         JFactory::getApplication()->close();
         return;
     }
     //se arrivo qui non è ne una presence ne una send
     $this->returnError('invalid data', 400);
 }
开发者ID:AlexRed,项目名称:Ozio-Chat,代码行数:101,代码来源:chat.php


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