2016-10-01 2 views
1

Я не знаю, почему я не могу сделать объект из следующего класса. Ошибка, которую я получаю:Как сделать объект Vimeo?

«Класс» 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

Try: new Vimeo\Vimeo(...), я имею в виду, везде вы используете класс Vimeo, вы должны сказать Vimeo\Vimeo.

Это из-за пространства имен php. Вы можете найти его для получения дополнительной информации.

Надеюсь, что это сработает!

Смежные вопросы