Reply
Contributor
Nathan
Posts: 35
Registered: 12-12-2008
0
Accepted Solution

Error while implementing Media Write API: PHP Example - Upload Video

I've tried implementing the video upload using the media API and PHP (as directed here: http://support.brightcove.com/en/docs/media-write-api-php-example-upload-video).  However, after the attempted upload, I am returned the following error:

 

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /htdocs/www/temp/uploadVideo.php on line 32

The only modification to the files was adding my read/write media API tokens as indicated here:

The following PHP script handles the upload form and uploads the video. You will need to provide valid tokens for your account on lines 12 and 13, replacing [[READ_TOKEN]] and [[WRITE_TOKEN]] with your own tokens.

 

 

 

New Member
ks535
Posts: 2
Registered: 02-05-2011
0

Re: Error while implementing Media Write API: PHP Example - Upload Video

I am having the same issue myself:

 

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/html/ ....

 

I also tried changing the "$bc =new Brightcove(" to: "$bc = new Echove(" since that's what I've used in other Echove uses, but I still got the same error.

Contributor
Nathan
Posts: 35
Registered: 12-12-2008
0

Re: Error while implementing Media Write API: PHP Example - Upload Video

I'm not familiar PHP whatsoever, but my friend says that this chunk of code should be changed from: 

 

 

class Brightcove {
	$this->token_read = '';
	$this->token_write = '';
	$this->read_url = 'http://api.brightcove.com/services/library?';
	$this->write_url = 'http://api.brightcove.com/services/post';

 

 

to:

 

 

class Brightcove
{
public $token_read = '';
public $token_write = '';
public $read_url = 'http://api.brightcove.com/services/library?';
public $write_url = 'http://api.brightcove.com/services/post';

 

Somehow, he was able to upload a video, but the return page was not very convincing that this is a valid solution.

 

 

Brightcove Team
BC-MCongrove
Posts: 21
Registered: 12-12-2008
0

Re: Error while implementing Media Write API: PHP Example - Upload Video

 

Syntax errors usually deal with a missing quote, semi-colon, or something like that. In this case it's improper object-oriented programming :)
This part of the code:
$this->token_read = '';
$this->token_write = '';
$this->read_url = 'http://api.brightcove.com/services/library?';
$this->write_url = 'http://api.brightcove.com/services/post';

 

Should look like this:
public $token_read = '';
public $token_write = '';
public $read_url = 'http://api.brightcove.com/services/library?';
public $write_url = 'http://api.brightcove.com/services/post';

 



Also, even if you fix that, this code is completely backwards (literally!). All the code above the "class Brightove" should be AFTER the class ends.

As a final note, this code is not Echove. It was loosely based on Echove; if you want to do PHP video uploads I highly suggest you get the actual Echove code (which has been renamed and can now be found here: http://opensource.brightcove.com/project/PHP-MAPI-Wrapper/
If you look in the examples section you'll also see how to do video uploads quite easily.

 

Matthew Congrove
Software Solutions Engineer | Professional Services
Contributor
Nathan
Posts: 35
Registered: 12-12-2008
0

Re: Error while implementing Media Write API: PHP Example - Upload Video

Thanks Michael. I'll give the Echove code a try.  It might be worthwhile to update the code in the example if you think it's a little wrong to help others.

 

Best.

Brightcove Team
BC-MCongrove
Posts: 21
Registered: 12-12-2008
0

Re: Error while implementing Media Write API: PHP Example - Upload Video

I'll notify the documentation manager sometime today :)

Matthew Congrove
Software Solutions Engineer | Professional Services