本文整理汇总了PHP中Pusher::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Pusher::get方法的具体用法?PHP Pusher::get怎么用?PHP Pusher::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pusher
的用法示例。
在下文中一共展示了Pusher::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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';
//.........这里部分代码省略.........