Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Video Upload using PHP example, setting value for Author


Hello,

As you know, there are metadata fields for every video stored using BOTR. One such field can be found on the Metadata tab and is called "Author" - if you are not familiar, on the Metadata tab you will find Author, Description, Link, and other custom properties.

After the video is uploaded, I will be able to 'update' the values of the video, for example: Change the title, add a description, change the author or thumbnail, etc...

If I wanted to set an Author during UPLOAD, how can this be done using the PHP API example for upload? What about also a custom variable and value?

Author: Jeremy
Custom1: Value1

The most important piece of the upload code is

bc.. <?php
require_once('botr/init_api.php');

# Do the API call to build an upload URL.
# The 'token' MUST be the last parameter for upload progress to work.
$response = $botr_api->call('/videos/create');
$token = $response['link']['query']['token'];
if ($response['status'] == 'error') { die(print_r($response)); }
$url = 'http://'.$response['link']['address'].$response['link']['path'];
$url .= '?key='.$response['link']['query']['key'];
$url .= '&api_format=xml';
$url .= '&redirect_address=http://'.$_SERVER["SERVER_NAME"].'/uploadstatus.php';
$url .= '&token='.$token;

?>



Could you help me add the Author field and value, and Custom field and value, into the upload code here?

Thank you!

*Note: The actual uploader and upload status page implemented on my site are working great!*
and I do not see a place where I could throw in additional fields here.

15 Community Answers

Remco van Bree

JW Player Support Agent  
0 rated :

This is not possible to do during the upload call.

As you might have noticed we gather title tags and description in step 1 of the upload in the dashboard. That is because that way we at the beginning of step 2 we can pass along this metadata in the /videos/create call.

So long story short: you will have to gather this metadata either before or after the upload button.

JW Player

User  
-1 rated :

But as I was saying in my first post, I -will- know who the author is going to be in Step 1, BEFORE the user hits the browse button to upload a video.

I'm not using the dashboard, I'm using the API. Assume that I know the author, how can I have that field set as soon as the upload happens?

JW Player

User  
0 rated :

A video cannot be uploaded without ownership, it needs to be set automatically to the person who is logged in and doing the upload. I just want to make it clear that I know who the author is before we upload.

Remco van Bree

JW Player Support Agent  
-1 rated :

You would have to pass along the author while doing the /videos/create call in this case.

http://developer.longtailvideo.com/botr/system-api/methods/videos/create.html

JW Player

User  
-1 rated :

remco I am trying to do the same thing. I would like my website user to be able to fill out all of the fields of information such as the Title, Description, Tags, etc. etc. Is there a working example of this some where?

thanks

Israel

Remco van Bree

JW Player Support Agent  
-1 rated :

I’m afraid there isn’t a premade example for this.

Essentially you will have to do the following:
1. Have a page where you gather the information that you want pre-filled out before people upload a video
2. Funnel that information into a /videos/create call that is used in the example.

This tutorial might also be useful for you: http://www.longtailvideo.com/support/bits-on-the-run/15985/update-video-properties-in-php

JW Player

User  
2 rated :

Hey Remco thank you I got this working and my users are able to upload videos from the font end of the website.

The only thing I cannot get to work is the progress bar during file upload. I am using the javascript from the php-example files.

The piece that does not seem to be working is just the calculation ... the rest of the javascript is fine:

Here is the form, could you run through it and tell me what I am doing wrong?

http://theimgweb.com/video-submission

thanks

Israel

Remco van Bree

JW Player Support Agent  
0 rated :

If I look at this page with the error console open, I see that you link to jquery, but that that link 404’s. I suspect that is causing this.

JW Player

User  
-1 rated :

Hey Remco can you send me screenshot?

I am not able to re-produce this issue and I checked the path to jquery and it appears to be correct but maybe something is happening i can't see


thank you for your help.

Remco van Bree

JW Player Support Agent  
-2 rated :

see http://imgur.com/g0jd1

JW Player

User  
-1 rated :

Hey Remco here is the code I am using in the page. I am not using that Jquery link that is getting a 404 error, I actually don't know where that is coming from.


/**********THIS IS AT THE TOP OF THE PAGE*********************/
bc.. <script type="text/javascript" src="http://theimgweb.com/wp-content/themes/child/js/jquery.js"></script>
<script type="text/javascript" src="http://theimgweb.com/wp-content/themes/child/js/jquery.uploadProgress.js"></script>


/********* THEN I HAVE THE BOTR UPLOAD FORM HERE**********************************/

bc.. DO STUFF HERE


/********* THEN HERE IS THE JAVASCRIPT FUNCTION*************************************/
bc.. <script type="text/javascript">
$(document).ready(function() {
// Attach an uploadProgress instance to the form. This tool will poll the server for progress.
$('#uploadForm').uploadProgress({
// The javascript paths are needed because uploadProgress builds an iframe that sits on top of the page.
jqueryPath: "http://theimgweb.com/wp-content/themes/child/js/jquery.js",
uploadProgressPath: "http://theimgweb.com/wp-content/themes/child/js/jquery.uploadProgress.js",
// The uploadProgress bar had just been inserted into the form.
progressBar: '#uploadProgress',
// This is the BOTR callback for upload progress.
progressUrl: 'http://upload.bitsontherun.com/progress',
// The token is needed to request fallback. It is pulled from the form.
uploadToken: $('#uploadToken').val(),
interval:1000,
// When the upload starts, we hide the input, show the progress and disable the button.
start: function() {
filename = $("#uploadFile").val().split(/[/]/).pop();
$("#uploadFile").css('display','none');
$("#uploadBar").css('display','block');
$("#uploadButton").attr('disabled','disabled');
},
// During upload, we update both the progress div and the text below it.
uploading: function(upload) {
if (upload.percents == 100) {
window.clearTimeout(this.timer);
} else {
$("#uploadText").html('Uploading ' + filename + ' (' + upload.percents + '%) ...');
}
}
});
});
</script>


Both of the paths to the Javascript Function and Jquery are correct.

thank you for your help!

best,

Israel

JW Player

User  
1 rated :

So if you go here:

http://theimgweb.com/video-submission

And fill out the form and then get to the video upload page you will see what you upload a video, part of the javascript works but the Progrss bar doesn't work.

Thanks again for your help:

best,

Israel

Remco van Bree

JW Player Support Agent  
0 rated :

There is a database error now. As a rule, you should start with the base example that comes with the API examples and make sure that works and then start adding your own stuff until something breaks, so you know what change you introduced broke things.

JW Player

User  
0 rated :

Hey Remco this is the exact code from the API, the only difference is that it is in wordpress.

The videos upload fine, the only issue is the Progress Bar information is not getting displayed.

If you go through and try and upload a test video you will see what I mean.

I really appreciate your help!

best,

Israel

Remco van Bree

JW Player Support Agent  
0 rated :

I don’t see any error when running your code, but given that the code as provided in our API examples does show the upload progress, while your page doesn’t, there is clearly some change that you introduced that caused it.

The only difference I can see is that in your page the uploadprogress script isn’t referenced in the <head> of the page.

This question has received the maximum number of answers.