Ejemplo n.º 1
0
 function sendRequest($method = null, $args = null, $postmethod = 'get')
 {
     $result = parent::sendRequest($method, $args, $postmethod);
     if (is_null($result)) {
         throw new ViddlerException("No response", $method, 8888, 'n/a');
     }
     if (is_array($result) && isset($result['error'])) {
         throw new ViddlerException($result['error']['description'], $method, $result['error']['code'], $result['error']['details']);
     }
     return $result;
 }
Ejemplo n.º 2
0
<?php

// These examples are in PHP 5.
include '../php5viddler.php';
$v = new Phpviddler('');
// Get an API key by going to You > Profile & API on Viddler.
?>
<!DOCTYPE html>
<html>
	<head>
		<title>PHPViddler 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/method-videos-getbyuser/">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->videos_listbyuser('viddlerdevtest', 1, 5);
// Loop through videos showing just the thumbnail
// with a link to the video itself.
foreach ($videos['video_list']['video'] as $video) {
    echo '<a href="' . $video['url'] . '"><img src="' . $video['thumbnail_url'] . '" alt="thumbnail" width="60" /></a> ';
}
?>
</p>
Ejemplo n.º 3
0
<?php

// 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.
?>
<!DOCTYPE html>
<html>
	<head>
		<title>PHPViddler 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/method-videos-getbyuser/">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->videos_listbyuser('viddlerdevtest', 1, 5);
// Loop through videos showing just the thumbnail
// with a link to the video itself.
foreach ($videos['video_list']['video'] as $video) {
    echo '<a href="' . $video['url'] . '"><img src="' . $video['thumbnail_url'] . '" alt="thumbnail" width="60" /></a> ';
}
?>
</p>
Ejemplo n.º 4
0
<?php

// 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.
?>
<!DOCTYPE html>
<html>
	<head>
		<title>PHPViddler POST Examples</title>
		
	</head>
	
	<body>
		<h1>PHPViddler POST Examples</h1>
		<p>A few simple examples of POSTing data to Viddler's API using PHPViddler.</p>
		
		<h2><a href="http://developers.viddler.com/documentation/api/method-users-auth/">viddler.users.auth</a></h2>
		<p>A quick example of authenticating a user.</p>
		
		<form method="post" action="postExamples.php">
			<p><label for="username">Username:</label> <input type="text" id="username" name="username" /></p>
			<p><label for="password">Password:</label> <input type="password" id="password" name="password" /></p>
			<p><input type="submit" value=" Test login " />
		</form>
		
		<p><?php 
if ($_POST) {
    // Search videos: type=allvideos, query=iphone, videos 5
    $user = $v->user_authenticate($_POST['username'], $_POST['password']);