Vimeo PRO 계정이 있습니다. 보호 된 비디오를 업로드했습니다. 비디오도 내 도메인에 임베드 가능하도록 설정되어 있습니다 (비디오 설정에서 설정)VIMEO (Pro) JSON 응답 도움말 (PHP/CURL)
예제를 사용하는 방법을 알지 못합니다. (미안, 저에게 실제 예제가 포함되어 있지 않습니다. .. 또는 적어도 이해하는 그들을 구현하는 방법 .. 그래서 도움을 얻으려고)
OAuth2, Oembed ... 인증 물건 중 하나라도 .. 분명히 내 문제는 어디에 거짓말.
https://github.com/vimeo/vimeo-api-examples/blob/master/oembed/php-example.php
(꽤 오래된 것 같아요?) 내가 ID가 함께 전달 될 때 JSON 데이터가 비디오에 대해 반환 얻기 위해 찾고 있어요
:
것은 나는이 GitHub의 예 다음되었다.
응답/반환 데이터를 받기 전에 '인증'해야한다는 인상하에 있었습니까?
CURL 헤더 또는 그 밖의 것이 가장 좋습니까?
나를 좀 더 안내 할 수 있습니까? (야해이 어려울!) 하하 .. 여기
내 코드입니다 :$video_endpoint = 'https://api.vimeo.com/videos/';
$video_url = '171811266';
//JSON url
//$json_url = $video_endpoint . '.json?url=' . rawurlencode($video_url);
//this fixes the cURL approach
$json_url = $video_endpoint . rawurlencode($video_url);
// Curl helper function
function curl_get($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization : bearer xxxxxx'));
$return = curl_exec($curl);
curl_close($curl);
return $return;
}
$vimeoJSON = json_decode((curl_get($json_url)));
var_dump($vimeoJSON);
그리고 나는이 응답을 얻을 :
object(stdClass)#1 (1) { ["error"]=> string(52) "You must provide a valid authenticated access token." }
질문은 다음과 같습니다
1.)입니다 이것도 유효한 접근법인가? (응답을 받기 전에 인증을 보내려면 CURL 헤더에 몇 줄의 코드를 추가해야한다고 가정하십시오.)
2.) VIEWO 인증과 함께 작동하도록 내 CURL 스 니펫을 어떻게 업데이트합니까?
는 내가 ..합니다 (JSON 호출/리턴 부분에 대한) 모든 지침이 감사 수 SIMPLE/청결이 유지하기 위해 노력하고있어.
감사
갱신 :
이 코드가 작동하지 않습니다
$access_token = 'xxx';
$video_endpoint = 'https://api.vimeo.com/videos/';
$video_url = '171811266';
$json_url = $video_endpoint . '.json?url=' . rawurlencode($video_url);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $json_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer ".$access_token
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
내가 여기에 사용하려는 비디오는 :
https://vimeo.com/171811266/5822169b48
IT는 IS 사적인 비디오. (확실하지 당신은 그것을 볼 수 있습니다) ..
을 나는이 응답을 얻을 .. 내가 위에 게시 된 코드의 최신 버전을 사용하는 경우 :
{"error":"The requested video could not be found"}
이 그것 때문에 비공개 동영상인가를 ?
(실제로는 그냥 누구나 볼 수 있도록 비디오를 설정 .. 그리고 난 여전히 같은 오류/응답있어) (찾을 수 없음)
그렇다면 .. 사용할 수있는 수정은 무엇인가를 내 비디오 .. 개인으로 설정되어 있지만 ... 내 사이트/도메인에서 여전히 그들을 사용합니까?
============================================== =============================
최종 업데이트 :
추가 정보 예제 코드를 사용하려고 : lib 디렉토리 @Dashron이 너무 나를 지적 (UN-성공적으로)를 사용하려고 https://github.com/vimeo/vimeo.php
.. 심지어 기초가 GIT 페이지에서 작동하도록하는 것 캔트 :
코드 :
//project vars
$client_id = 'xxxx';
$client_secret = 'xxx';
$access_token = 'xxx';
$redirect_uri = 'http://domain.com/file.php'; //where do I redirect them back to? the page where I have the embeded video at?
// scope is an array of permissions your token needs to access. You can read more at https://developer.vimeo.com/api/authentication#scopes
$scopes = Array('public', 'private');
$state = 'Ldhg0478y';
require("Vimeo/autoload.php");
$lib = new Vimeo\Vimeo($client_id, $client_secret);
// build a link to Vimeo so your users can authorize your app. //whatever that means and is for?
$url = $lib->buildAuthorizationEndpoint($redirect_uri, $scopes, $state);
// redirect_uri must be provided, and must match your configured uri
$token = $lib->accessToken(code, redirect_uri);
// usable access token
var_dump($token['body']['access_token']);
// accepted scopes
var_dump($token['body']['scope']);
// use the token
$lib->setToken($token['body']['access_token']);
나는이 오류 메시지가 얻을 :
Parse error: syntax error, unexpected Fatal error: Class 'Vimeo\Vimeo' not found in /usr/www/users/aaemorg/aaem.org/video/vimeo_lib.php
는 내 $ lib 디렉토리 오브젝트/클래스의 인스턴스를 생성하지 것 같다을 ??
(저는 PHP 수준의 코드/코드가 좋지 않다는 것을 알고 있습니다.하지만이 부조리하게도 난 비디오 사이트의 JSON 응답을 얻으 려합니다.
어떤 방향으로 생각하니?
============================================== ========================
업데이트 : "어떤 날 위해 일했습니다"..
나는에 대한 링크를 감사하고 '공식 라이브러리'..하지만 readme 예제는 나를 위해 작동하지 않았다 ...
Vimeo API를 처음 사용하는 사람들에게 쉽고 편리하게 .... 여기가 빠르고 더러운 것입니다. 간단한 코드 샘플 얻으려면 및 실행 :
,363,210<?
//include offifial library
require("Vimeo/autoload.php");
$client_id = 'xxx';
$client_secret = 'xxx';
$access_token = 'xxx';
$video_id = 'xxx';
$lib = new Vimeo\Vimeo($client_id, $client_secret, $access_token);
$video_response = $lib->request('/videos/'.$video_id);
//dont really need this, but included in case there is some data you need to display
$token_response = $lib->clientCredentials();
//example of parsing out specific data from the array returned
//name/title
echo $video_response['body']['name'] . '<br><br>';
?>
@Cfreak - 보조에 대한 감사합니다! (내가 이상한 글을 쓰고있다.) – whispers