I need some help on a youtube api called thumbnails:set.
I implemented oauth to my account, already a youtube partner and got a developer key.
I would want to know on how to use the HTTP request which is "POST https://www.googleapis.com/youtube/v3/thumbnails/set" with videoId as its parameter and implement it in php.
In general, I would like to know how to upload a custom thumbnail and pass it using the API towards youtube.
here's the link of the api: https://developers.google.com/youtube/v3/docs/thumbnails/set#try-it
You can use the YouTube php client library. You will use
$setResponse = $youtube->thumbnails->set("YOUR_VIDEO_ID",
array('mediaUpload' => $media));
where media is your media upload as in
$media = new Google_MediaFileUpload('image/*', null, true, $chunkSizeBytes);
$media->setFileSize(filesize($videoPath));
The rest of the code will be OAuth2. You can always use the framework I introduced as an answer to My zend application is unable to upload files on youtube
Related
I am trying to use URL as a video source to create a video post on Facebook using facebook's PHP SDK for graph API. I am trying to use uploadVideo method from the example given on https://developers.facebook.com/docs/php/howto/example_upload_video/
This method gives error
filesize(): stat failed for <URL>
It is trying to read file by using filesize() and it is not possible to use URL as the source.
The problem is while making the POST request to Facebook I have only access to the video URL and it will not be feasible to download on the local machine and post it to Facebook.
So is there other methods to use URL to post a video to Facebook?
After going through the source code for PHP SDK and how the uploadVideo method work. I found 'videoToUpload' method.
$response = $facebook->post('/'.$fb_page_id.'/videos', array(
'description' => $postData['description'],
'source' => $facebook->videoToUpload($media)
), $access_token);
This method works. But I am not sure if this is the right way to go.
I'm having trouble finding a simplified tutorial for using the Vimeo API I know I need to include vimeo.php and the following
include 'vimeo.php';
$vimeo = new phpVimeo('Client Identifier', 'Client Secrets');
$videos = $vimeo->call('vimeo.videos.getUploaded', array('user_id' => "user1877648"));
print_r($videos);
I've copied and pasted the fields I've used from the access Authentication in case that's where the issue is, I've also read that for simple calls to the API don't need access tokens?
I could really do with some pointers as to how I get a list of vimeo thumbs linking to the vimeo url from a specific user? I was using the older code and up until recently it worked well.
Dashron pointed you to all of the correct places to find the documentation needed to do what you are trying to do.
However, here is an example of how you would do it.
You need to download / clone the Vimeo PHP Library (found here: https://github.com/vimeo/vimeo.php).
Then go to Vimeo and create an app so you can acquire a client id and client secret (https://developer.vimeo.com/api/start).
Now that you have a client id, client secret, and the vimeo library, you can create a simple script to load all of the videos from a specific user. Here is an example:
<?php
// include the autoload file from the vimeo php library that was downloaded
include __DIR__ . '/vimeo/autoload.php';
// The client id and client secret needed to use the vimeo API
$clientId = "";
$clientSecret = "";
// when getting an auth token we need to provide the scope
// all possible scopes can be found here https://developer.vimeo.com/api/authentication#supported-scopes
$scope = "public";
// The id of the user
$userId = "alexbohs";
// initialize the vimeo library
$lib = new \Vimeo\Vimeo($clientId, $clientSecret);
// request an auth token (needed for all requests to the Vimeo API)
$token = $lib->clientCredentials($scope);
// set the token
$lib->setToken($token['body']['access_token']);
// request all of a user's videos, 50 per page
// a complete list of all endpoints can be found here https://developer.vimeo.com/api/endpoints
$videos = $lib->request("/users/$userId/videos", ['per_page' => 50]);
// loop through each video from the user
foreach($videos['body']['data'] as $video) {
// get the link to the video
$link = $video['link'];
// get the largest picture "thumb"
$pictures = $video['pictures']['sizes'];
$largestPicture = $pictures[count($pictures) - 1]['link'];
}
Keep in mind that the vimeo API returns "pages" of videos. So if the user has more than 50 videos per page you would need to do a request for each page by specifying the page number using "page" parameter (Change ['per_page' => 50] to ['per_page' => 50, 'page' => #].
This is the old, Advanced API. It is deprecated.
The new PHP library is here: https://github.com/vimeo/vimeo.php
The new API docs are here: https://developer.vimeo.com/api
The endpoint to retrieve all of your videos is https://api.vimeo.com/me/videos (https://developer.vimeo.com/api/endpoints/me#/videos)
Just wondering how I would delete a video from YouTube using v3 of the API using the official Google PHP library.
I see this here:
Deleting a video from a playlist with YouTube Data API v3
$youtubeService = new Google_YouTubeService($client);
$playlistItems = $youtubeService->playlistItems;
$deleteVid = $playlistItems->delete($videocode);
Not sure if this is correct - does this work if the video is not in a playlist?
I also have the code for v2 of the API
Deleting YouTube videos using Zend/PHP
$videoEntryToDelete = $yt->getVideoEntry($videoId, null, true);
$yt->delete($videoEntryToDelete);
But rather use v3
For those looking for the answer it was this:
$youtube = new Google_Service_YouTube($client);
...
//do your authoraisation stuff + getting access token etc
...
$youtube->videos->delete('<Your Video ID>');
Hope that helps!
Uploading videos to a YouTube account without a channel fails.
I'm using the YouTube Data API (Version 3) and the Google APIs Client Library for PHP to upload custom videos to a users channel. The user has given authorization (via OAuth2) to manage their YouTube account, but it's possible that the user has never created a YouTube channel.
The question is: How do I check if the user has a valid channel before trying to start an upload? Ideally, I'd want to check right after authentication.
After a valid oAuth token is received, you can make the following call (this assumes that '$youtube' represents your Google_YoutubeService object):
$channelsResponse = $youtube->channels->listChannels('contentDetails', array(
'mine' => 'true',
));
If $channelsResponse['items'] is empty, then the authenticated user has no channels.
http get calls for 'https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key={}&access_token={}'
will return items even if the user does not has channels.
an example response is:
{u'etag': u'"IHLB7Mi__JPvvG2zLQWweA"',
u'items': [{u'contentDetails': {u'googlePlusUserId': u'107123',
u'relatedPlaylists': {u'favorites': u'FLMZmB78WMw',
u'likes': u'LLMZmB78we',
u'uploads': u'UUMZmB78Wwef',
u'watchHistory': u'HLMZmB78Wwe',
u'watchLater': u'WLMZmB78WMDgwef'}},
u'etag': u'"IHLB7Mi__JPvvG2zLQWAg8l36"',
u'id': u'UCMZmB78WMD',
u'kind': u'youtube#channel'}],
u'kind': u'youtube#channelListResponse',
u'pageInfo': {u'resultsPerPage': 1, u'totalResults': 1}}
in case that 'googlePlusUserId' is in response, then the user has channel.
I want to know if is there a way to upload the tumbnails with its video using the APIs Advanced API /Upload API of VIMEO.
I am giving an answer by using PHP language.
This library can be used for vimeo api integration:
https://github.com/vimeo/vimeo-php-lib
After uploading videos, try below solution to create thumbnails for videos:
Get img thumbnails from Vimeo?
I sent an email to the api developers community to ask about this point and the answer was :
The advanced api does not currently support assigning thumbnails to videos. We will look into adding this feature in the future, but I can not give you a time frame at the moment.
I'm using latest Vimeo API's.
I tried this and it worked for me.
$lib = new \Vimeo\Vimeo($client_id, $client_secret);
$lib->setToken($access_token);
$video_uri = $lib->upload('video.mp4', false);
$metadata = array(
'name' => "Video Title",
'description' => "Description comes here"
);
$response = $lib->request($video_uri, $metadata, 'PATCH');