我想在模塊中嵌入vimeo視頻播放列表腳本,但我有獲取$ token參數的問題。Joomla - 獲取參數到外部文件
這是文件在那裏我得到了VIMEO鍵,祕密和令牌使用官方的PHP庫:https://github.com/vimeo/vimeo.php
外網絡的根的settings.php:
define('_JEXEC', 1);
define('JPATH_BASE', realpath(dirname(__FILE__).'/../../../..'));
define('DS', DIRECTORY_SEPARATOR);
require_once (JPATH_BASE .DS.'includes'.DS.'defines.php');
require_once (JPATH_BASE .DS.'includes'.DS.'framework.php');
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$user =& JFactory::getUser();
$session =& JFactory::getSession();
jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_module');
$moduleParams = new JRegistry();
$moduleParams->loadString($module->params);
$vkey = $moduleParams->get('vimkey');
$vsecret = $moduleParams->get('vimsecret');
$vtoken = $moduleParams->get('vimtoken');
$key = '$vkey';
$secret = '$vsecret';
$token = '$vtoken';
腳本正確得到$vkey
和$vsecret
params但不是$vtoken
。我在控制檯上得到這個錯誤:
您必須提供一個有效的經過身份驗證的訪問令牌。
,我得到這個爲的$ vtoken
string(32) "3wsrsdf234mytoken2342werwr"
後續代碼var_dump但是,當我更改參數不$令牌:
$token = '3wsrsdf234mytoken2342werwr';
然後腳本正常工作。我該如何解決這個問題?
vimeo_data.php
require_once("../../outside-web-root-settings.php");
if(!isset($_REQUEST['type']) || !isset($_REQUEST['page']) || !isset($_REQUEST['per_page']) || IsNullOrEmpty($key) || IsNullOrEmpty($secret) || IsNullOrEmpty($token)) exit("PHP Vimeo information missing!");
function IsNullOrEmpty($v){
return (!isset($v) || trim($v)==='');
}
$type = $_REQUEST['type'];
$page = $_REQUEST['page'];
$per_page = $_REQUEST['per_page'];
$path = isset($_REQUEST['path']) && !IsNullOrEmpty($_REQUEST['path']) ? $_REQUEST['path'] : null;
$user = isset($_REQUEST['user']) && !IsNullOrEmpty($_REQUEST['user']) ? $_REQUEST['user'] : null;
$query = isset($_REQUEST['query']) && !IsNullOrEmpty($_REQUEST['query']) ? $_REQUEST['query'] : null;
$sort = isset($_REQUEST['sort']) && !IsNullOrEmpty($_REQUEST['sort']) ? $_REQUEST['sort'] : 'date';
require("../autoload.php");
use Vimeo\Vimeo;
$vimeo = new Vimeo($key, $secret, $token);
if($type == 'vimeo.channel'){
//Get a list of videos in a Channel - https://developer.vimeo.com/api/playground/channels/{channel_id}/videos
$result = $vimeo->request("/channels/$path/videos", array(
'page'=> $page,
'per_page' => $per_page,
'fields' => 'uri,name,description,duration,width,height,privacy,pictures.sizes',
'sort' => $sort,
'direction' => 'asc',
'query' => $query));
}
echo json_encode($result);