Skip to content

Commit

Permalink
Updated readme and added multiple thumbnails example
Browse files Browse the repository at this point in the history
  • Loading branch information
phpfunk committed Oct 4, 2012
1 parent 5ad41b9 commit 4e93c31
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 38 deletions.
42 changes: 4 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
# Examples
### Thumbnails | [Download](https://github.com/viddler/Examples/zipball/thumbnails)

The master branch of this repository is only holding the readme file that you are currently reading. If you'd like to [download all](https://github.com/viddler/Examples/zipball/all) the examples please checkout the `all` branch, otherwise simple checkout the branch you would like to download or switch to that branch then download.
* multiple.php : How to extract all the thumbnails associated to a particular video ID

***
This example can be found in the `all` branch as well as the `thumbnails` branch if you only want to grab this example.

### All Examples | [Download](https://github.com/viddler/Examples/zipball/all)

This is a package of all the examples listed below.

***

### Direct Upload | [Download](https://github.com/viddler/Examples/zipball/direct-upload)

Two files that will show an example of upload a file directly from your site to Viddler and a simple callback script to get the video id or errors returned.

This example can be found in the `all` branch as well as the `direct-upload` branch if you only want to grab this example.

To read the published article about this example, please click [here](http://blog.viddler.com/cdevroe/direct-upload-api/).

***

### Direct Upload using cURL | [Download](https://github.com/viddler/Examples/zipball/direct-upload-curl)

This is a simple example of how you can still transmit files to viddler from server to server instead of directly from consumer to our servers. If you like to upload the files to your server first, you still can. The file included in this example will allow you to upload that file to us using cURL and mimicking submitting a traditional HTML form.

This example can be found in the `all` branch as well as the `direct-upload-curl` branch if you only want to grab this example.

To read the published article about this example, please click [here](http://blog.viddler.com/phpfunk/direct-upload-using-curl/).

***

### Direct Upload with Progress Bar | [Download](https://github.com/viddler/Examples/zipball/upload-progress)

A collection of files that will extend the direct upload form by submitting the form to an iframe in order to allow you to use AJAX in order to build a proper progress bar.

This example can be found in the `all` branch as well as the `upload-progress` branch if you only want to grab this example.

You will need to have a Viddler API key and update the the `progress.php` and `index.php` page with your Viddler username and password to run this example.

You can view the working example [here](http://public.supportserver.viddler.com/upload-progress/).
To read the published article about this example, please click [here](http://blog.viddler.com/phpfunk/multiple-thumbnails/).
55 changes: 55 additions & 0 deletions thumbnails/multiples.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?
include '/path/to/viddler/api/';

$v = new Viddler_V2('API_KEY');
$auth = $v->viddler_users_auth(array(
'user' => 'YOUR USERNAME',
'password' => 'YOUR PASSWORD'
));

/**
- Check for the session id
- If not found, there was an error
- You will want to handle this error better than the example below.
- You should never print out errors to your production system
**/
if (! isset($auth['auth']['sessionid'])) {
print '<pre>';
print_r($auth);
print '</pre>';
exit;
}

//Get Thumbnails
$video = $v->viddler_videos_getDetails(array(
'sessionid' => $auth['auth']['sessionid'],
'video_id' => 'VIDEO_ID'
));

/**
- Check for thumbnails count
- If not found, there was an error
- You will want to handle this error better than the example below.
- You should never print out errors to your production system
**/
if (! isset($video['video']['thumbnails_count'])) {
//Handle no thumbnails error
}

//Original Thumb and Total Thumbs
$org_thumb = $video['video']['thumbnail_url'];
$total_thumbs = $video['video']['thumbnails_count'];

//Looping and show medium thumb version of each
for ($i = 0; $i < $total_thumbs; $i++) {

//Replace _2_ with _1_ to get medium thumb rather than large
$tmp_thumb = str_replace('_2_', '_1_', $org_thumb);

//Regex to replace _v# with current thumb
$tmp_thumb = preg_replace('/(.*?)(_v[0-9])(\..*?)/', "$1_$i$3", $tmp_thumb);

//Display it
print '<img src="' . $tmp_thumb . '" width="114" height="86" border="0" />';
}
?>

0 comments on commit 4e93c31

Please sign in to comment.