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');
Related
Hello everyone,
I was working on a project where i need to display a video specifically from my google drive on a webpage. I don't want to manually select the video and copy its embed code, is there a way we can obtain the embed code for a video using google api (PHP preferred) ?
So that i can use this code within an iframe and display the video.
Please also suggest if there are other ways.
Thanks in advance,
You can start with Google Drive API https://developers.google.com/drive/v3/web/quickstart/php and this segment of code i hope can help you.
<?php
// New Google Client, see all settings at link in description
$client = new Google_Client();
// New Google Drive Service
$service = new Google_Service_Drive($client);
// Params with filter of MIME type for search only videos mp4 (you can change this)
$optParams = [
'q' => "mimeType='video/mp4'",
'pageSize' => 10,
'fields' => 'nextPageToken, files(id, name, webViewLink)'
];
// Get files from our request
$files = $service->files->listFiles($optParams);
// Print an iframe for each video
foreach($files->files as $file){
// Now I need to make a little detail about the next lines of code so look at [Info]
$src = str_replace('/view', '/preview', $file->webViewLink);
echo '<iframe width="500" height="200" target="_parent" src="'. $src .'"></iframe>'
}
?>
[Info]
The objects returned from $service->files->listFiles($optParams) are Google_Service_Drive_DriveFile objects and each of these have a series of properties. From v3 of Google API a properties called embedLink was removed and there isn't an alternative for this property from v2(Migrate to Google Drive API v3) so as you seen in my code i use webViewLink property that return a URL to a view of file like this:
https://drive.google.com/file/d/123456789/view
But if you use this URL inside an <iframe> the browser notice to you an error:
Refused to display 'https://drive.google.com/file/d/123456789/view' in a frame because it set 'X-Frame-Options' to 'sameorigin'.`
I'm not holding you too much on this issue and there are a lot of question about this. So we need to request a preview of file and not a view an i do that with
str_replace('/view', '/preview', $file->webViewLink);
on the URL returned by the request. Now you can use this URL in a <iframe>
Instead of video if I'll upload photo with same code its working fine.
$post_data = array('type' => 'video', 'caption' => 'hello video','data' => $video_path);
$createPost = $tumblr->createPost($unique_id,$post_data);
I'm getting this error while uploading:
Tumblr\API\RequestException: [400]: Bad Request (You may only upload one video per post.)
There was an issue in the official Tumblr API v2 PHP Client. I had created a pull request here.
Either take a pull or update your local code to fix your code.
It's possible to set age restriction individually/manually via the Web UI, but it's not possible to set globally for a channel or account as far as I can see.
Is it possible to set via API when uploading a video?
The point is to avoid banning if I upload a video on behalf of another user, and I don't get time to screen the video.
Thanks in advance,
Anders
Update 1:
This is how I found I should do, according to https://developers.google.com/youtube/v3/docs/videos:
$contentRating = new Google_Service_YouTube_ContentRating();
$contentRating->setYtRating('ytAgeRestricted');
$details = new Google_Service_YouTube_VideoContentDetails();
$details->setContentRating($contentRating);
$video->setContentDetails($details);
Remarkably there's not a single example of use of Google_Service_YouTube_VideoContentDetails anywhere.
When this data is added to the video, the upload fails with the following. Clearly YouTube didn't like my setting. Is the use of age-restriction in itself restricted?
Google_Exception::__set_state(array(
'message' => 'Failed to start the resumable upload (HTTP 400: youtube.part, contentDetails)',
'string' => '',
'code' => 0,
'file' => '/home/u/u6554025/www/twitizer.com/Google/Http/MediaFileUpload.php',
'line' => 300,
Update 2:
That's a bummer if true:
http://gadgetsytecnologia.com/de585c5edb2f3a366/uploading-video-via-youtube-api.html
"You can read this property as: contentDetails.contentRating.ytRating = "ytAgeRestricted" but it looks like you can't POST this property in the video Resource in the body of your POST request to Youtube API"
Neither does the official documentation mention that insert supports contentRating.
Live and learn. Adopt, adapt, improve.
If anyone has any idea how to circumvent this, possibly with a global setting for the channel, I'm all ears.
Thanks,
Anders
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
I have written an Application what posts Photos on a FanPage into a Specific Album long time ago.
Now I didn't used for a half year. Now I had to set up the Application again and grant the extended Permissions to the Fan Page (streamm_publish) again.
But now I've a Problem, I'm using the old REST API what now gives me the error: An unknown error ocurred with the error code 1.
Then I tried to post throught the Facebook Graph api.
I tried to make a call to the Api /pageid/albumid/photos what's not working(Unknown path components)
I tried to makea a call to /albumid_from_my_page/photos then the Photos were posted to my profile
I tried to upload it to /pageid/photos what is the same as the one above
But the code fpr the REST Api worked well, what's the problem there, and why the new Graph Api isn't working how she should?(BUG?)
To post a photo to an album, this is the code:
$post_data = array(
"message" => "My photo caption",
"source" => '#' . realpath($file)
);
$album_id = "XXXXX";
$facebook->api("/$album_id/photos", 'post', $post_data);
Now I suppose to interact with the page albums you need a page access_token added to your $post_data array, for this check this answer.
You need take ACCESS_TOKEN page...
try:
http://graph.facebook.com/me/accounts?access_token= GET THIS TOKEN USING GRAPH API... OR MAKE USING the getAccessToken()...
and will see all pages and aplications that u have, find just application for this case and COPY TOKEN... and damn!!!
It's possible to see this token thought GRAPH API EXPLORER...
regards.