= 5.1.4 * This sample is run from within a web browser. These files are required: * session_details.php - a script to view log output and session variables * operations.php - the main logic, which interfaces with the YouTube API * index.php - the HTML to represent the web UI, contains some PHP * video_app.css - the CSS to define the interface style * video_app.js - the JavaScript used to provide the video list AJAX interface * * NOTE: If using in production, some additional precautions with regards * to filtering the input data should be used. This code is designed only * for demonstration purposes. */ session_start(); /** * Set your developer key here. * * NOTE: In a production application you may want to store this information in * an external file. */ $_SESSION['developerKey'] = ''; /** * Convert HTTP status into normal text. * * @param number $status HTTP status received after posting syndicated upload * @param string $code Alphanumeric description of error * @param string $videoId (optional) Video id received back to which the status * code refers to */ function uploadStatus($status, $code = null, $videoId = null) { switch ($status) { case $status < 400: echo 'Success ! Entry created (id: '. $videoId . ') (check details)'; break; default: echo 'There seems to have been an error: '. $code . '(check details)'; } } /** * Helper function to check whether a session token has been set * * @return boolean Returns true if a session token has been set */ function authenticated() { if (isset($_SESSION['sessionToken'])) { return true; } } /** * Helper function to print a list of authenticated actions for a user. */ function printAuthenticatedActions() { print <<

Authenticated Actions

END; } ?> YouTube data API Video Browser in PHP

YouTube data API Video App in PHP

click to examine session variables


Authentication status: END; } else { print <<Click here to generate authentication link
END; } ?>

' . uploadStatus($_GET['status'], $code, $id) . '
'; } ?>