Vimeo Basic

Tags

Vimeo 객체 생성 예시

형식 : $client = new Vimeo("{client_id}", "{client_secret}", "{access_token}");
//설정 예시 $client = new Vimeo("123", "abc", "a1b");

앱 등록

앱 등록하고 토큰 받아야 API 사용 가능.
  1. My Apps 페이지로 이동
  1. Create an app 버튼 클릭.
  1. App Name & App Description 입력
  1. end user가 앱을 다운로드하거나 관련정보를 얻을 수 있는 URL 표기
  1. Vimeo API 라이센스 등 동의 체크
  1. Create App 클릭
notion image

Vimeo SDK 설정

(개발환경 설정) Vimeo API와 연결하고 상호작용하려면 개발환경 셋팅 필요

다양한 환경 지원

https://developer.vimeo.com/api/libraries (전체 지원 환경 목록)

Node.js 기준 설치

$ npm install vimeo

엑세스 토큰 생성

Vimeo Authentication

엑세스 토큰?

엑세스 토큰 이 있어야 API 요청 가능.
  • 앱과 유저 유형
  • 권한 식별
  • API로 생성 or My Apps 페이지에서 생성 가능

개인용 액세스 토큰 생성

  1. My Apps 페이지
  1. 등록한 앱 클릭
  1. Generate an access token 부분 확인
  1. 스코프, 권한 지정해서 토큰 생성
  1. 업로드 권한은 별도 요청 필요. (검토 후 발급됨)
notion image
  • 영상 시청용, 관리자용 토큰 생성해서 DB에 저장.
  • 토큰 관리 어떻게??

Vimeo API 호출 예시

HTTP 직접 요청도 가능

We've also included the HTTP code in cURL and as HTTP if you'd rather map the HTTP commands to your own request library instead of using our SDKs. You don't need your client ID or client secret for this sort of operation, but you do need to supply your access token. It belongs in the Authorization header, after the keyword bearer and a space,
like this: bearer {access_token}.
⇒ SDK 안쓰고 HTTP 요청을 직접 날려도 됨. 헤더에 `bearer ${access_token}` 만 셋팅하면 됨.

SDK 사용 예시

Node.js 기준
//require let Vimeo = require('vimeo').Vimeo; //Vimeo 객체 생성 let client = new Vimeo("{client_id}", "{client_secret}", "{access_token}"); //Vimeo 객체를 통한 http 요청 송수신 client.request({ method: 'GET', path: '/tutorial' }, function (error, body, status_code, headers) { if (error) { console.log(error); } console.log(body); })

에러핸들링

  1. client ID, client secret, access token 설정 잘 했는지 확인
  1. 실패 response를 잘 읽어봐라
      • user_message : 그냥 일반적인 에러사항 출력 (기술적인 부분 X)
      • developer_message : 디버깅을 위한 더 많은 정보 포함 (기술적인 부분 O)
  1. 엑세스 토큰 재발급