我不知道为什么我不能从下面的类中创建一个对象。 我得到的错误是:
“未找到”Vimeo'类别。“
请有人可以告诉我我哪里出错了吗?
我的php:
require_once('Vimeo/Vimeo.php');
$client_id = '1234';
$client_secret = 'abcd';
$vimeo = new Vimeo($client_id, $client_secret, $access_token = null);
Vimeo班级:
namespace Vimeo;
use Vimeo\Exceptions\VimeoUploadException;
use Vimeo\Exceptions\VimeoRequestException;
class Vimeo
{
const ROOT_ENDPOINT = 'https://api.vimeo.com';
const AUTH_ENDPOINT = 'https://api.vimeo.com/oauth/authorize';
const ACCESS_TOKEN_ENDPOINT = '/oauth/access_token';
const CLIENT_CREDENTIALS_TOKEN_ENDPOINT = '/oauth/authorize/client';
const REPLACE_ENDPOINT = '/files';
const VERSION_STRING = 'application/vnd.vimeo.*+json; version=3.2';
const USER_AGENT = 'vimeo.php 1.0; (http://developer.vimeo.com/api/docs)';
const CERTIFICATE_PATH = '/certificates/vimeo-api.pem';
private $_client_id = null;
private $_client_secret = null;
private $_access_token = null;
protected $_curl_opts = array();
protected $CURL_DEFAULTS = array();
/**
* Creates the Vimeo library, and tracks the client and token information.
*
* @param string $client_id Your applications client id. Can be found on developer.vimeo.com/apps
* @param string $client_secret Your applications client secret. Can be found on developer.vimeo.com/apps
* @param string $access_token Your applications client id. Can be found on developer.vimeo.com/apps or generated using OAuth 2.
*/
public function __construct($client_id, $client_secret, $access_token = null)
{
$this->_client_id = $client_id;
$this->_client_secret = $client_secret;
$this->_access_token = $access_token;
$this->CURL_DEFAULTS = array(
CURLOPT_HEADER => 1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => true,
//Certificate must indicate that the server is the server to which you meant to connect.
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CAINFO => realpath(__DIR__ .'/../..') . self::CERTIFICATE_PATH
);
}
答案 0 :(得分:0)
尝试:new Vimeo\Vimeo(...)
,我的意思是,在您使用Vimeo课程的任何地方,都应该说Vimeo\Vimeo
。
这是因为php命名空间。您可以谷歌搜索更多信息。
希望它有效!