2016-10-01 25 views
1

我不知道为什么我不能从下面的课程中创建一个对象。 我得到的错误是:如何制作Vimeo物件?

“Class'Vimeo'not found”。

请有人能告诉我我要去哪里错了吗?

我的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

尝试:new Vimeo\Vimeo(...),我的意思是,无论你使用Vimeo的类,你应该说Vimeo\Vimeo

这是因为php的命名空间。你可以谷歌它的进一步信息。

希望它的作品!