Skip to content

Commit

Permalink
Added functions and examples for Viddler short URL service.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdevroe committed Mar 2, 2010
1 parent 201c810 commit 6ff849e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
8 changes: 7 additions & 1 deletion examples/getExamples.php
Expand Up @@ -3,7 +3,7 @@
// These examples are in PHP 5.

include('../php5viddler.php');
$v = new Phpviddler('YOUR API KEY HERE'); // Get an API key by going to You > Profile & API on Viddler.
$v = new Phpviddler(''); // Get an API key by going to You > Profile & API on Viddler.

?>
<!DOCTYPE html>
Expand Down Expand Up @@ -62,6 +62,12 @@
?>
<p>Note: If Avatar is blank you should use default. More profile variables are available, review doc.</p>

<h2>Creating a Viddler short URL</h2>
<p>Create a short URL using http://go.viddler.com/ using the following URL as an example:<br />URL: <a href="http://www.viddler.com/explore/cdevroe/videos/133/">http://www.viddler.com/explore/cdevroe/videos/133/</a></p>

<?php $shortURL = $v->video_go('http://www.viddler.com/explore/cdevroe/videos/133/');?>
<p>Short URL: <a href="<?=$shortURL;?>"><?=$shortURL;?></a></p>

<p>Please feel free to add more examples. Most GET requests return similar results though.</p>


Expand Down
18 changes: 17 additions & 1 deletion phpviddler.php
Expand Up @@ -14,7 +14,7 @@
# XML Library by Keith Devens
# xmlparser.php
#
# Version 0.6
# Version 0.7
########################################################
*/

Expand Down Expand Up @@ -470,6 +470,22 @@ function video_getoEmbed($videourl,$maxwidth) {
return $embedcode;
}

/* video_go()
/ description: Creates a Viddler short URL using http://go.viddler.com/
/ accepts: $url(string) - must be full URL e.g. http://www.viddler.com/explore/cdevroe/videos/133/
/ returns: string or false if invalid URL.
/ added by: Colin Devroe on March 2, 2010 while listening to Spoon for the first time.
*/
function video_go($url) {
//! To do: Send URL to Viddler API.
$response = $this->video_detailsbyurl($url);

if (isset($response['error'])) {
return false;
} else {
return 'http://go.viddler.com/'.$response['video']['id'].'/';
}
}

/* buildArguments()
/ accepts: $p(array)
Expand Down

0 comments on commit 6ff849e

Please sign in to comment.