Exemplo n.º 1
0
<html>
	<head>
		<title>PHPViddler API v2 GET Examples</title>
		
	</head>
	
	<body>
		<h1>PHPViddler GET Examples</h1>
		<p>A few simple examples of retrieving some videos from Viddler's API using PHPViddler.</p>
		
		
		<h2><a href="http://developers.viddler.com/documentation/api-v2/">viddler.videos.getByUser</a></h2>
		<p>Some videos based on a user - viddlerdevtest (a Viddler account we use for testing)</p>
		<p><?php 
// Get videos (page 1, videos 5)
$videos = $v->viddler_videos_getByUser(array('user' => 'viddlerdevtest', 'per_page' => 5, 'page' => 1));
/* Debug only 
		echo '<pre>';
		print_r($videos);
		echo '</pre>';
		*/
// Loop through videos showing just the thumbnail
// with a link to the video itself.
foreach ($videos['list_result']['video_list'] as $video) {
    echo '<a href="' . $video['url'] . '"><img src="' . $video['thumbnail_url'] . '" alt="thumbnail" width="60" /></a> ';
}
?>
</p>
		
		
		<h2><a href="http://developers.viddler.com/documentation/api-v2/">viddler.videos.search</a></h2>
Exemplo n.º 2
0
<?php

//Example to auth as you and get your videos
include '../phpviddler.php';
//Create viddler object using HTTPS:443
$v = new Viddler_V2('YOUR API KEY', TRUE);
//Authenticate as you
//Always a good idea even if your profile/videos are public
//Because if at anytime you turn to a private account
//Your application will still work ;)
$auth = $v->viddler_users_auth(array('user' => 'YOUR USERNAME', 'password' => 'YOUR PASSWORD'));
//Get your session id
$session_id = isset($auth['auth']['sessionid']) ? $auth['auth']['sessionid'] : '';
//If no session id, print errors
if (!empty($session_id)) {
    $videos = $v->viddler_videos_getByUser(array('sessionid' => $session_id, 'per_page' => 5, 'page' => 1));
    //If any errors print them out
    //This should NOT be done in a production application
    //An exception should be used instead
    //For example purposes only
    if (isset($videos['error'])) {
        echo '<pre>';
        print_r($videos);
        echo '</pre>';
        exit;
    }
    $videos = isset($videos['list_result']['video_list']) ? $videos['list_result']['video_list'] : array();
} else {
    echo '<pre>';
    print_r($auth);
    echo '</pre>';