Let's imagine that I have a video url on my site: it's like this: http://example.com/videos/myvideo.mp4 . I want to use Automatic (“pull”) uploads method to upload this video to vimeo. Then I simply want to host it on my site. The problem is that the documentation that they provide is kinda confusing to me (and possibly all other developers getting started with their api). So, from your experience can you tell me how to upload this video to that vimeo and get back the video url that has been uploaded?
I created the vimeo app as they said and I have requested the upload access. It says:
Upload Access
Approved for the following accounts:
Your account
So basically everything is setup. I just need to know what http request should I send to the vimeo server in order to upload that mp4 file that is accessible on the web.
The HTTP request is detailed in the pull upload section of the documentation: https://developer.vimeo.com/api/upload/videos#automatic-pull-uploads
An HTTP POST request to https://api.vimeo.com/me/videos with two required, and one optional parameter sent through the request body.
The official PHP library: https://github.com/vimeo/vimeo.php will help you make the upload request, and documentation on making requests using this library is located here: https://github.com/vimeo/vimeo.php#make-requests
Once you have all the pieces together, the request looks kind of like this:
$response = $lib->request('/me/videos', ['type'=>'pull','link'=>$url], 'POST');
Related
I am attempting to use the Gallery3 REST API to upload an image. According to the limited API documentation I should be posting new items to this endpoint /index.php/rest/item/1.
Documentation: http://codex.galleryproject.org/Gallery3:API:REST#Example_create_request
Can anyone confirm this because I keep getting failed to open stream: HTTP request failed!
I am able to connect to the gallery, get member albums, and get photos. I just can't seem to upload new photos to the gallery.
Yes, that is the correct URL. I was able to create an album by posting to that URL using Postman. My error seems to have something to do with my PHP ... specifically something to do with stream_context_create() and/or file_get_contents().
I am creating an API-centric web application using PHP. I have read a lot of articles on API-centric arhitecture and design, but I have a problem related to file uploads.
Suppose I have an image and I want to upload it to the API server. How should I upload that image and how then to receive the link to that image?
Here is how I want to create it now:
Select an image using <input type="file"> on client www.domain.com
Upload it to the www.domain.com using POST with multipart/form-data
Send this image with PUT/POST API call to the api.domain.com
api.domain.com will save this image to another server like static.domain.com and will store image's id in the database
Then, when I will need this image, I can use GET API call to the api.domain.com and I will receive image's url (something like static.domain.com/image.jpg)
Aditional questions:
Is this approach the right one or I am doing completely wrong?
Will I need an aditional server to store uploaded files if my application will be small, or I can store files right on the API server?
If I will store images on same server as API server, won't it be strange if image urls will look like api.domain.com/image.jpg?
P.S: We can skip a lot of API-related things as I need only an idea on how to deal with file uploads.
You haven't really said what kind of API that you are going to be implementing here, so I assume that it is just a restful API.
Is this approach the right one or I am doing completely wrong?
No, I wouldn't say you're doing it wrong. You would essentially send the file using POST.
Will I need an aditional server to store uploaded files if my application will be small, or I can store files right on the API server?
Yes, it will allow you to store this on the same server, I don't see why not. I doubt that you will use a lot of storage, if the application is small.
If I will store images on same server as API server, won't it be strange if image urls will look like api.domain.com/image.jpg?
The api.domain.com/image.jpg technically is just the URL that you connect to the API with and GET/POST data. It does not mean the file is going to be that URL. The API could return like:
{
type: "IMG",
id: "1",
url: "example.com/uploads/image.jpg"
}
I hope this this helps, even a little!
I have Implemented an WhatsAPI - PHP on my site, but am only able to
send messages but not the Media files like Images, Audio or Video.
I got the WhatsApp API for PHP
This is my screen.
I am not getting how to send an image or any other media files through this API.
I have tried all url for image sending like.
http://www.sample.com/images/sample.jpg
C:\Users\Public\Pictures\Sample Pictures\sample.jpg
But it still not able to send any media file.
Please let me know how to send an image from this API. What am doing wrong....?
as i read the example functions in the API files you will see this,
//send picture
$w->sendMessageImage($target, "demo/x3.jpg");
and of this code you may need to pass the image absolute url to the api
since you are working on localhost, you may not success sending the image, you may need to try it on real server.
and the image should be on same server NOT external image url
I Hope this also will work. Please try and let us know the result.
while($w->pollMessage()); after $w->sendMessageImage($target, "demo/x3.jpg");
I need to know a method to upload a video to a VIMEO PRO account using a form and PHP (to get auth). Currently I can send a video directly to Vimeo, using the panel, as was to be expected. But I have some clients that want to upload your videos directly from my their control panel (created by me), outside of vimeo, and I have only a unique PRO account, and I can't share the account data.
Seems that I can do it, based on the page API https://developer.vimeo.com/apis/advanced/upload#post (Uploading via POST).
My doubts are:
Can I really do that, without pass to my clients the Vimeo PRO account data?
It's a secure method (considering that clients respect the agreement with Vimeo)?
I need to upload DIRECTLY to Vimeo, without pass to my server, because I'll have two works: one to upload to server, other to upload from server to vimeo.
Off-topic: I believe I will not have problems with Vimeo, since they are customers of one company, and the account belongs to the company, and the videos will be her responsibility.
How should work
User access my panel, with your credentials;
User access the video upload page;
Probably the server will contact Vimeo to get an uploader auth;
User will select your vimeo file and submit form;
System will receive the vimeo ID and everyone will be happy forever.
Thanks!
Edit: This feature is now supported by Vimeo's (in beta) API3. You can request access at https://vimeo.com/help/contact
The below information is still accurate in regards to the Advanced API
This feature is not reliably supported by the advanced api.
The primary issue is that with client side uploads, there is no way to tell the upload server what to do once the upload is complete. Additionally, there is no client side technique to find out whether the upload has completed
You might be able to cheat and have the user upload through an iframe, and have the primary page perform a verify chunks call every couple of seconds. I have not tried this, at the moment it is just a theory. If you attempt this hack, Vimeo would love to know more via their contact page https://vimeo.com/help/contact
The feature you are discussing is on the roadmap for the next version of the API, and an early imperfect version was available at their API Hackday. It might be a better idea to hold off a bit and wait for the official feature.
NOTE: This observation does NOT apply to server side uploads. Because the whole upload process is handled via code on the server, it is extremely easy to tell when an upload is complete.
Answering in 2016: Assuming you have already retrieved an access token from Vimeo (OAuth2) this is a good piece of code to help you create an upload form:
https://github.com/websemantics/vimeo-upload
This gives you the code for the form with a place to drag-drop your video file and calls the upload API:
If you're using WordPress, there is a plugin available that allows you to do just that
http://vimeography.com/add-ons/vimeography-upload/
Source: I made it :)
I have video files stored on my web server which I want to be able to upload to YouTube in an automated kind of way. These videos are created on my website, which then the user can just upload to their YouTube Channel.
I am trying to make HTTP request calls to automate this video upload process, according to the Resumable Video Upload process here: https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_uploads
Everything works fine (getting the user's access permission, sending the metadata of the video) until the final step, which is the upload of the video itself. When I make the PUT request, it returns a response code 417 and says Invalid Request. Like this:
The following error was encountered:
Invalid Request
Some aspect of the HTTP Request is invalid. Possible problems:
Missing or unknown request method
Missing URL
Missing HTTP Identifier (HTTP/1.0)
Request is too large
Content-Length missing for POST or PUT requests
Illegal character in hostname; underscores are not allowed
I took a look at all those suggested possible problems, but I cannot find a fault anywhere in my code.
And the error message is just to vague and not specific enough to tell me where the problem is.
I am performing every step of the video upload process using the PHP's standard Http Request class. (http://www.php.net/manual/en/class.httprequest.php)
Here is my code:
$videoFile = *Some Video File*;
$httpRequest = new httpRequest($_SESSION['youtube_data_api']['upload_url'], HttpRequest::METH_PUT);
$httpRequest->setContentType('video/mp4');
$httpRequest->setPutFile($videoFile);
$headersArr = array('Content-Length' => strlen($httpRequest->getRawRequestMessage()));
$httpRequest->setHeaders($headersArr);
$httpMessage = $httpRequest->send();
I dug around on the internet a lot regarding this question, and a lot of times what I found are people using the Zend framework's YouTube library to accomplish this instead, which is a lot easier. Unfortunately, with the size of my website right now, it is just not feasible to spend some much time trying to integrate framework into my website.
Any insight into this problem would help tremendously! Thanks!