|
@@ -1,703 +0,0 @@
|
|
|
-<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
-<!-- EN-Revision: 24249 -->
|
|
|
|
|
-<!-- Reviewed: no -->
|
|
|
|
|
-<sect1 id="zend.gdata.youtube">
|
|
|
|
|
- <title>Verwenden der YouTube Daten API</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die YouTube Daten <acronym>API</acronym> bietet einen Lese- und Schreibzugriff auf YouTube
|
|
|
|
|
- Inhalte. Benutzer können nicht authentifizierte Anfragen zu Google Daten Feeds durchführen
|
|
|
|
|
- um Feeds von populären Videos, Kommentare, öffentliche Informationen über YouTube
|
|
|
|
|
- Benutzerprofilen, Benutzer PlayListen, Favoriten, Einschreibungen und so weiter zu erhalten.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Für weitere Informationen über die YouTube Daten <acronym>API</acronym> schauen Sie in die
|
|
|
|
|
- offizielle <ulink
|
|
|
|
|
- url="http://code.google.com/apis/youtube/developers_guide_php.html"><acronym>PHP</acronym>
|
|
|
|
|
- Entwickler Dokumentation</ulink> auf code.google.com.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.authentication">
|
|
|
|
|
- <title>Authentifizierung</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die YouTube Daten <acronym>API</acronym> erlaubt aktuell einen nur-lesenden Zugriff auf
|
|
|
|
|
- öffentliche Daten, welcher keine Authentifizierung benötigt. Für alle schreibenden
|
|
|
|
|
- Anfragen muß sich ein Benutzer entweder mit ClientLogin oder AuthSub authentifizieren.
|
|
|
|
|
- Schauen Sie bitte in das <ulink
|
|
|
|
|
- url="http://code.google.com/apis/youtube/developers_guide_php.html#Authentication">Kapitel
|
|
|
|
|
- über Authentifizierung in der <acronym>PHP</acronym> Entwickler
|
|
|
|
|
- Dokumentation</ulink> für weitere Details.
|
|
|
|
|
- </para>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.developer_key">
|
|
|
|
|
- <title>Entwickler Schlüssel und Client ID</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Ein Entwickler Schlüssel identifiziert den QouTube Entwickler der die
|
|
|
|
|
- <acronym>API</acronym> Anfrage schickt. Eine Client ID identifiziert die Anwendung für
|
|
|
|
|
- Logging und Debugging Zwecke. Schauen Sie bitte auf <ulink
|
|
|
|
|
- url="http://code.google.com/apis/youtube/dashboard/">http://code.google.com/apis/youtube/dashboard/</ulink>
|
|
|
|
|
- um einen Entwickler Schlüssel und eine Client ID zu erhalten. Das angefügte Beispiel
|
|
|
|
|
- demonstriert wie der Entwickler Schlüssel und die Client ID an das <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube.html">Zend_Gdata_YouTube</ulink>
|
|
|
|
|
- Service Pbjekt übergeben werden.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.developer_key.example">
|
|
|
|
|
-
|
|
|
|
|
- <title>
|
|
|
|
|
- Einen Entwicklerschlüssel und eine ClientID an Zend_Gdata_YouTube übergeben
|
|
|
|
|
- </title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube($httpClient,
|
|
|
|
|
- $applicationId,
|
|
|
|
|
- $clientId,
|
|
|
|
|
- $developerKey);
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.videos">
|
|
|
|
|
- <title>Öffentliche Video Feeds empfangen</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die YouTube Daten <acronym>API</acronym> bietet eine Vielzahl von Feeds die eine Liste
|
|
|
|
|
- von Videos zurückgeben, wie zum Beispiel Standard Feeds, Abhängige Videos, Antworten auf
|
|
|
|
|
- Videos, Videobewertungen, Benutzer Uploads, und Benutzer Favoriten. Zum Beispiel gibt
|
|
|
|
|
- der Benutzer Upload Feed alle Videos zurück die von einem speziellen Benutzer
|
|
|
|
|
- hochgeladen wurden. Sehen Sie in den <ulink
|
|
|
|
|
- url="http://code.google.com/apis/youtube/reference.html#Video_Feeds">You Tube
|
|
|
|
|
- <acronym>API</acronym> Referenz Guide</ulink> für eine detailierte Liste aller
|
|
|
|
|
- vorhandenen Feeds.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <sect3 id="zend.gdata.youtube.videos.searching">
|
|
|
|
|
- <title>Suchen nach Videos durch Metadaten</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Man kann eine Liste von Videos erhalten die einem speziellen Suchkriterium
|
|
|
|
|
- entsprechen, indem die YouTubeQuery Klasse verwendet wird. Die folgende Abfrage
|
|
|
|
|
- schaut nach Videos welche das Wort "Katze" in Ihren Metadaten enthalten, beginnend
|
|
|
|
|
- mit dem 10ten Video und 20 Videos pro Seite anzeigt, sortiert nach der Anzahl der
|
|
|
|
|
- Ansichten.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.searching.example">
|
|
|
|
|
- <title>Suchen nach Videos</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$query = $yt->newVideoQuery();
|
|
|
|
|
-$query->videoQuery = 'cat';
|
|
|
|
|
-$query->startIndex = 10;
|
|
|
|
|
-$query->maxResults = 20;
|
|
|
|
|
-$query->orderBy = 'viewCount';
|
|
|
|
|
-
|
|
|
|
|
-echo $query->queryUrl . "\n";
|
|
|
|
|
-$videoFeed = $yt->getVideoFeed($query);
|
|
|
|
|
-
|
|
|
|
|
-foreach ($videoFeed as $videoEntry) {
|
|
|
|
|
- echo "---------VIDEO----------\n";
|
|
|
|
|
- echo "Titel: " . $videoEntry->mediaGroup->title->text . "\n";
|
|
|
|
|
- echo "\nBeschreibung:\n";
|
|
|
|
|
- echo $videoEntry->mediaGroup->description->text;
|
|
|
|
|
- echo "\n\n\n";
|
|
|
|
|
-}
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Für weitere Details über die verschiedenen Abfrageparameter, kann der <ulink
|
|
|
|
|
- url="http://code.google.com/apis/youtube/reference.html#Searching_for_videos">Referenz
|
|
|
|
|
- Guide</ulink> hilfreich sein. Die vorhandenen Hilfsfunktionen in <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_VideoQuery.html">
|
|
|
|
|
- <classname>Zend_Gdata_YouTube_VideoQuery</classname></ulink> für jeden dieser
|
|
|
|
|
- Parameter werden im <ulink
|
|
|
|
|
- url="http://code.google.com/apis/youtube/developers_guide_php.html#SearchingVideos">PHP
|
|
|
|
|
- Entwickler Guide</ulink> detailierter beschrieben.
|
|
|
|
|
- </para>
|
|
|
|
|
- </sect3>
|
|
|
|
|
-
|
|
|
|
|
- <sect3 id="zend.gdata.youtube.videos.searchingcategories">
|
|
|
|
|
- <title>Suchen nach Videos durch Kategorien und Tags/Schlüsselwörter</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die Suche nach Videos in speziellen Kategorien wird durch die Erstellung einer
|
|
|
|
|
- <ulink url="http://code.google.com/apis/youtube/reference.html#Category_Search">
|
|
|
|
|
- speziell formatierten <acronym>URL</acronym></ulink> durchgeführt. Um, zum Beispiel,
|
|
|
|
|
- nach Komödien-Videos zu suchen die das Schlüsselwort Hund enthalten:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.searchingcategories.example">
|
|
|
|
|
- <title>Suchen nach Videos in speziellen Kategorien</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$query = $yt->newVideoQuery();
|
|
|
|
|
-$query->category = 'Comedy/Hund';
|
|
|
|
|
-
|
|
|
|
|
-echo $query->queryUrl . "\n";
|
|
|
|
|
-$videoFeed = $yt->getVideoFeed($query);
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect3>
|
|
|
|
|
-
|
|
|
|
|
- <sect3 id="zend.gdata.youtube.videos.standard">
|
|
|
|
|
- <title>Standard Feeds empfangen</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die YouTube Daten <acronym>API</acronym> hat eine Anzahl an <ulink
|
|
|
|
|
- url="http://code.google.com/apis/youtube/reference.html#Standard_feeds">Standard
|
|
|
|
|
- Feeds</ulink>. Diese Standard Feeds können als <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_VideoFeed.html">Zend_Gdata_YouTube_VideoFeed</ulink>
|
|
|
|
|
- Objekte empfangen werden indem die spezifizierten <acronym>URL</acronym>s und die in
|
|
|
|
|
- der <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube.html">Zend_Gdata_YouTube</ulink>
|
|
|
|
|
- Klasse vordefinierten Konstanten (zum Beispiel
|
|
|
|
|
- Zend_Gdata_YouTube::STANDARD_TOP_RATED_URI) oder die vordefinierten Hilfsmethoden
|
|
|
|
|
- verwendet verwendet werden (siehe das Codebeispiel anbei).
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Um die Top gereihten Videos zu erhalten kann die folgende Helfermethode verwendet
|
|
|
|
|
- werden:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.standard.example-1">
|
|
|
|
|
- <title>Empfangen eines Standard Videofeeds</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$videoFeed = $yt->getTopRatedVideoFeed();
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Es gibt auch Abfrageparameter um eine Zeitperiode zu spezifizieren über die der
|
|
|
|
|
- Standardfeed berechnet wird.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Um zum Beispiel die Top gereihten Videos von Heute zu erhalten:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.standard.example-2">
|
|
|
|
|
- <title>Verwenden von Zend_Gdata_YouTube_VideoQuery um Videos zu empfangen</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$query = $yt->newVideoQuery();
|
|
|
|
|
-$query->setTime('today');
|
|
|
|
|
-$videoFeed = $yt->getTopRatedVideoFeed($query);
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Alternativ kann man den Feed erhalten indem die <acronym>URL</acronym> verwendet
|
|
|
|
|
- wird:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.standard.example-3">
|
|
|
|
|
- <title>Empfangen eines Video Feeds durch die URL</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$url = 'http://gdata.youtube.com/feeds/standardfeeds/top_rated?time=today'
|
|
|
|
|
-$videoFeed = $yt->getVideoFeed($url);
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect3>
|
|
|
|
|
-
|
|
|
|
|
- <sect3 id="zend.gdata.youtube.videos.user">
|
|
|
|
|
- <title>Videos erhalten die von einem Benutzer hochgeladen wurden</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Man kann eine Liste von Videos erhalten die von einem bestimmten Benutzer
|
|
|
|
|
- hochgeladen wurden indem eine einfache Helfermethode verwendet wird. Dieses Beispiel
|
|
|
|
|
- empfängt Videos die vom Benutzer 'liz' hochgeladen wurden.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.user.example">
|
|
|
|
|
- <title>
|
|
|
|
|
- Empfangen von Videos die von einem spezifischen Benutzer hochgeladen wurden
|
|
|
|
|
- </title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$videoFeed = $yt->getUserUploads('liz');
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect3>
|
|
|
|
|
-
|
|
|
|
|
- <sect3 id="zend.gdata.youtube.videos.favorites">
|
|
|
|
|
- <title>Videos empfangen die von einem Benutzer bevorzugt werden</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Man kann eine Liste von bevorzugten Videos eines Benutzer erhalten indem eine
|
|
|
|
|
- einfache Helfermethode verwendet wird. Dieses Beispiel empfängt Videos die vom
|
|
|
|
|
- Benutzer 'liz' bevorzugt werden.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.favorites.example">
|
|
|
|
|
- <title>Empfangen von den bevorzugten Videos eines Benutzers</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$videoFeed = $yt->getUserFavorites('liz');
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect3>
|
|
|
|
|
-
|
|
|
|
|
- <sect3 id="zend.gdata.youtube.videos.responses">
|
|
|
|
|
- <title>Videobewertungen für ein Video erhalten</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Man kann eine Liste von Videobewertungen eines Videos erhalten indem eine einfache
|
|
|
|
|
- Helfermethode verwendet wird. Dieses Beispiel empfängt Videobewertungen für ein
|
|
|
|
|
- Video mit der ID 'abc123813abc'.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.responses.example">
|
|
|
|
|
- <title>Empfangen eines Feeds von Video Antworten</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$videoFeed = $yt->getVideoResponseFeed('abc123813abc');
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect3>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.comments">
|
|
|
|
|
- <title>Videokommentare erhalten</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die Kommentare für jedes YouTube Video können auf unterschiedlichen Wegen empfangen
|
|
|
|
|
- werden. Um die Kommentare für das Video mit der ID 'abc123813abc' zu empfangen kann der
|
|
|
|
|
- folgende Code verwendet werden:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.comments.example-1">
|
|
|
|
|
- <title>Empfangen eines Feeds von Videokommentaren von einer Video ID</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$commentFeed = $yt->getVideoCommentFeed('abc123813abc');
|
|
|
|
|
-
|
|
|
|
|
-foreach ($commentFeed as $commentEntry) {
|
|
|
|
|
- echo $commentEntry->title->text . "\n";
|
|
|
|
|
- echo $commentEntry->content->text . "\n\n\n";
|
|
|
|
|
-}
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Kommentare können für ein Video auch empfangen werden wenn man eine Kopie des <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_VideoEntry.html">Zend_Gdata_YouTube_VideoEntry</ulink>
|
|
|
|
|
- Objektes hat:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.videos.comments.example-2">
|
|
|
|
|
- <title>
|
|
|
|
|
- Empfangen eines Feeds von Videokommentaren von einem Zend_Gdata_YouTube_VideoEntry
|
|
|
|
|
- </title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$videoEntry = $yt->getVideoEntry('abc123813abc');
|
|
|
|
|
-// Die ID des Videos in diesem Beispiel ist unbekannt, aber wir haben die URL
|
|
|
|
|
-$commentFeed = $yt->getVideoCommentFeed(null,
|
|
|
|
|
- $videoEntry->comments->href);
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.playlists">
|
|
|
|
|
- <title>PlayList Feeds erhalten</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die YouTube Daten <acronym>API</acronym> bietet Informationen über Benutzer, inklusive
|
|
|
|
|
- Profile, PlayListen, Einschreibungen, und weitere.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <sect3 id="zend.gdata.youtube.playlists.user">
|
|
|
|
|
- <title>Die PlayListen eines Benutzer erhalten</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die Bibliothek bietet eine Helfermethode um die PlayListen, die einem angegebenen
|
|
|
|
|
- Benutzer zugeordnet sind, zu erhalten. Um die PlayListen des Benutzers 'liz' zu
|
|
|
|
|
- erhalten kann der folgende Code verwendet werden:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.playlists.user.example">
|
|
|
|
|
- <title>Empfangen von Playlisten eines Benutzers</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$playlistListFeed = $yt->getPlaylistListFeed('liz');
|
|
|
|
|
-
|
|
|
|
|
-foreach ($playlistListFeed as $playlistEntry) {
|
|
|
|
|
- echo $playlistEntry->title->text . "\n";
|
|
|
|
|
- echo $playlistEntry->description->text . "\n";
|
|
|
|
|
- echo $playlistEntry->getPlaylistVideoFeedUrl() . "\n\n\n";
|
|
|
|
|
-}
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect3>
|
|
|
|
|
-
|
|
|
|
|
- <sect3 id="zend.gdata.youtube.playlists.special">
|
|
|
|
|
- <title>Eine spezielle PlayListe erhalten</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die Bibliothek bietet eine Helfermethode um Videos zu erhalten die mit einer
|
|
|
|
|
- gegebenen PlayListe assoziiert sind. Um die PlayListe für einen speziellen PlayList
|
|
|
|
|
- Eintrag zu erhalten kann der folgende Code verwendet werden:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.playlists.special.example">
|
|
|
|
|
- <title>Empfangen von speziellen Playlisten</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$feedUrl = $playlistEntry->getPlaylistVideoFeedUrl();
|
|
|
|
|
-$playlistVideoFeed = $yt->getPlaylistVideoFeed($feedUrl);
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect3>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.subscriptions">
|
|
|
|
|
- <title>Eine Liste von Einschreibungen eines Benutzers erhalten</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Ein Benutzer kann verschiedene Arten von Einschreibungen besitzen: Kanal
|
|
|
|
|
- Einschreibungen, Tag Einschreibungen, oder Favoriten Einschreibungen. Ein <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_SubscriptionEntry.html">Zend_Gdata_YouTube_SubscriptionEntry</ulink>
|
|
|
|
|
- wird verwendet um individuelle Einschreibungen zu repräsentieren.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Um alle Einschreibungen für den Benutzer 'liz' zu erhalten kann der folgende Code
|
|
|
|
|
- verwendet werden:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.subscriptions.example">
|
|
|
|
|
- <title>Empfangen aller Einschreibungen eines Benutzers</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$subscriptionFeed = $yt->getSubscriptionFeed('liz');
|
|
|
|
|
-
|
|
|
|
|
-foreach ($subscriptionFeed as $subscriptionEntry) {
|
|
|
|
|
- echo $subscriptionEntry->title->text . "\n";
|
|
|
|
|
-}
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.profile">
|
|
|
|
|
- <title>Ein Benutzerprofil erhalten</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Die öffentlichen Profil Informationen kann man für jeden YouTube Benutzer erhalten. Um
|
|
|
|
|
- das Profil für den Benutzer 'liz' zu erhalten kann der folgende Code verwendet werden:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.profile.example">
|
|
|
|
|
- <title>Empfangen des Profils eines Benutzers</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube();
|
|
|
|
|
-$userProfile = $yt->getUserProfile('liz');
|
|
|
|
|
-echo "Benutzername: " . $userProfile->username->text . "\n";
|
|
|
|
|
-echo "Alter: " . $userProfile->age->text . "\n";
|
|
|
|
|
-echo "Heimatstadt: " . $userProfile->hometown->text . "\n";
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.uploads">
|
|
|
|
|
- <title>Videos auf YouTube hochladen</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Stellen Sie sicher das Sie die Diagramme im <ulink
|
|
|
|
|
- url="http://code.google.com/apis/youtube/developers_guide_protocol.html#Process_Flows_for_Uploading_Videos">Protokoll
|
|
|
|
|
- Guide</ulink> auf code.google.com für eine Übersicht des Upload Prozesses betrachtet
|
|
|
|
|
- haben. Das Hochladen von Videos kann auf 2 Wegen durchgeführt werden: Entweder durch das
|
|
|
|
|
- direkte Hochladen des Videos oder durch das Senden der Video Meta-Daten und indem der
|
|
|
|
|
- Benutzer das Video über ein <acronym>HTML</acronym> Formular hochlädt.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Um ein Video direkt hochzuladen, muß zuerst ein neues <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_VideoEntry.html">Zend_Gdata_YouTube_VideoEntry</ulink>
|
|
|
|
|
- Objekt erstellt und einige benötigte Meta-Daten spezifiziert werden. Das folgende
|
|
|
|
|
- Beispiel zeigt das Hochladen des Quicktime Videos "mytestmovie.mov" auf YouTube mit den
|
|
|
|
|
- folgenden Eigenschaften:
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <table id="zend.gdata.youtube.uploads.metadata">
|
|
|
|
|
- <title>Metadaten die im folgenden Code-Beispiel verwendet werden</title>
|
|
|
|
|
-
|
|
|
|
|
- <tgroup cols="2" align="left" colsep="1" rowsep="1">
|
|
|
|
|
- <thead>
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Eigenschaft</entry>
|
|
|
|
|
- <entry>Wert</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
- </thead>
|
|
|
|
|
-
|
|
|
|
|
- <tbody>
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Title</entry>
|
|
|
|
|
- <entry>My Test Movie</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
-
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Category</entry>
|
|
|
|
|
- <entry>Autos</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
-
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Keywords</entry>
|
|
|
|
|
- <entry>cars, funny</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
-
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Description</entry>
|
|
|
|
|
- <entry>My description</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
-
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Filename</entry>
|
|
|
|
|
- <entry>mytestmovie.mov</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
-
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>File <acronym>MIME</acronym> type</entry>
|
|
|
|
|
- <entry>video/quicktime</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
-
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Video private?</entry>
|
|
|
|
|
- <entry><constant>FALSE</constant></entry>
|
|
|
|
|
- </row>
|
|
|
|
|
-
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Video location</entry>
|
|
|
|
|
- <entry>37, -122 (lat, long)</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
-
|
|
|
|
|
- <row>
|
|
|
|
|
- <entry>Developer Tags</entry>
|
|
|
|
|
- <entry>mydevelopertag, anotherdevelopertag</entry>
|
|
|
|
|
- </row>
|
|
|
|
|
- </tbody>
|
|
|
|
|
- </tgroup>
|
|
|
|
|
- </table>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Der folgende Code erzeugt einen leeren <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_VideoEntry.html">Zend_Gdata_YouTube_VideoEntry</ulink>
|
|
|
|
|
- der Hochgeladen werden kann. Ein <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_App_MediaFileSource.html">Zend_Gdata_App_MediaFileSource</ulink>
|
|
|
|
|
- wird dann verwendet um die aktuelle Video Datei zu speichern. Unter der Hand wird ein
|
|
|
|
|
- <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_Extension_MediaGroup.html">Zend_Gdata_YouTube_Extension_MediaGroup</ulink>
|
|
|
|
|
- Objekt verwendet um alle Metadaten des Videos zu speichern. Die anbei beschriebenen
|
|
|
|
|
- Helfermethoden erlauben es die Metadaten des Videos zu setzen ohne das man sich um das
|
|
|
|
|
- Medien Gruppen Objekt kümmern muß. $uploadUrl ist der Ort an den der neue Eintrag
|
|
|
|
|
- gepostet wird. Er kann entweder durch $userName des aktuell authentifizierten Benutzers
|
|
|
|
|
- spezifiziert werden, oder, alternativ indem einfach der String 'default' verwendet wird
|
|
|
|
|
- um auf den aktuell authentifizierten Benutzer zu verweisen.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.uploads.example">
|
|
|
|
|
- <title>Ein Video hochladen</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube($httpClient);
|
|
|
|
|
-$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
|
|
|
|
|
-
|
|
|
|
|
-$filesource = $yt->newMediaFileSource('mytestmovie.mov');
|
|
|
|
|
-$filesource->setContentType('video/quicktime');
|
|
|
|
|
-$filesource->setSlug('mytestmovie.mov');
|
|
|
|
|
-
|
|
|
|
|
-$myVideoEntry->setMediaSource($filesource);
|
|
|
|
|
-
|
|
|
|
|
-$myVideoEntry->setVideoTitle('My Test Movie');
|
|
|
|
|
-$myVideoEntry->setVideoDescription('My Test Movie');
|
|
|
|
|
-// Beachte das category eine gültige YouTube Kategorie sein muß !
|
|
|
|
|
-$myVideoEntry->setVideoCategory('Comedy');
|
|
|
|
|
-
|
|
|
|
|
-// Setzt Keywords, beachte das es ein Komma getrennter String ist
|
|
|
|
|
-// und das keines der Schlüsselwörter ein Leerzeichen enthalten darf
|
|
|
|
|
-$myVideoEntry->SetVideoTags('cars, funny');
|
|
|
|
|
-
|
|
|
|
|
-// Optional Entwickler Tags setzen
|
|
|
|
|
-$myVideoEntry->setVideoDeveloperTags(array('mydevelopertag',
|
|
|
|
|
- 'anotherdevelopertag'));
|
|
|
|
|
-
|
|
|
|
|
-// Optional den Ort des Videos setzen
|
|
|
|
|
-$yt->registerPackage('Zend_Gdata_Geo');
|
|
|
|
|
-$yt->registerPackage('Zend_Gdata_Geo_Extension');
|
|
|
|
|
-$where = $yt->newGeoRssWhere();
|
|
|
|
|
-$position = $yt->newGmlPos('37.0 -122.0');
|
|
|
|
|
-$where->point = $yt->newGmlPoint($position);
|
|
|
|
|
-$myVideoEntry->setWhere($where);
|
|
|
|
|
-
|
|
|
|
|
-// URI hochladen für den aktuell authentifizierten Benutzer
|
|
|
|
|
-$uploadUrl =
|
|
|
|
|
- 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
|
|
|
|
|
-
|
|
|
|
|
-// Versuch das Video hochzuladen, eine Zend_Gdata_App_HttpException fangen wenn
|
|
|
|
|
-// Sie vorhanden ist oder nur eine reguläre Zend_Gdata_App_Exception
|
|
|
|
|
-
|
|
|
|
|
-try {
|
|
|
|
|
- $newEntry = $yt->insertEntry($myVideoEntry,
|
|
|
|
|
- $uploadUrl,
|
|
|
|
|
- 'Zend_Gdata_YouTube_VideoEntry');
|
|
|
|
|
-} catch (Zend_Gdata_App_HttpException $httpException) {
|
|
|
|
|
- echo $httpException->getRawResponseBody();
|
|
|
|
|
-} catch (Zend_Gdata_App_Exception $e) {
|
|
|
|
|
- echo $e->getMessage();
|
|
|
|
|
-}
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Um ein Video als privat hochzuladen muß einfach $myVideoEntry->setVideoPrivate();
|
|
|
|
|
- verwendet werden; bevor das Hochladen durchgeführt wird. $videoEntry->isVideoPrivate()
|
|
|
|
|
- kann verwendet werden um zu prüfen ob ein Video Eintrag privat ist oder nicht.
|
|
|
|
|
- </para>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.uploads.browser">
|
|
|
|
|
- <title>Browser-basierender Upload</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Browser-basierendes hochladen wird fast auf die gleiche Weise durchgeführt wie direktes
|
|
|
|
|
- Hochladen, ausser das man kein <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_App_MediaFileSource.html">Zend_Gdata_App_MediaFileSource</ulink>
|
|
|
|
|
- Objekt an den <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_VideoEntry.html">Zend_Gdata_YouTube_VideoEntry</ulink>
|
|
|
|
|
- anhängt den man erstellt. Stattdessen überträgt man einfach alle Metadaten des Videos um
|
|
|
|
|
- ein Token Element zurück zu erhalten welches verwendet werden kann um ein
|
|
|
|
|
- <acronym>HTML</acronym> Upload Formular zu erstellen.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.uploads.browser.example-1">
|
|
|
|
|
- <title>Browser-basierender Upload</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-$yt = new Zend_Gdata_YouTube($httpClient);
|
|
|
|
|
-
|
|
|
|
|
-$myVideoEntry= new Zend_Gdata_YouTube_VideoEntry();
|
|
|
|
|
-$myVideoEntry->setVideoTitle('My Test Movie');
|
|
|
|
|
-$myVideoEntry->setVideoDescription('My Test Movie');
|
|
|
|
|
-
|
|
|
|
|
-// Beachte das die Kategorie eine gültige YouTube Kategorie sein muß !
|
|
|
|
|
-$myVideoEntry->setVideoCategory('Comedy');
|
|
|
|
|
-$myVideoEntry->SetVideoTags('cars, funny');
|
|
|
|
|
-
|
|
|
|
|
-$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
|
|
|
|
|
-$tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
|
|
|
|
|
-$tokenValue = $tokenArray['token'];
|
|
|
|
|
-$postUrl = $tokenArray['url'];
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Der obige Code gibt einen Link und ein Token aus das verwendet wird um ein
|
|
|
|
|
- <acronym>HTML</acronym> Formular zu erstellen und im Browser des Benutzers anzuzeigen.
|
|
|
|
|
- Ein einfaches Beispielformular wird unten gezeigt mit $tokenValue welches den Inhalt des
|
|
|
|
|
- zurückgegebenen Token Elements darstellt, welches wie gezeigt, oben von $myVideoEntry
|
|
|
|
|
- empfangen wird. Damit der Benutzer, nachdem das Formular übermittelt wurde, auf die
|
|
|
|
|
- Website umgeleitet wird, muß ein $nextUrl Parameter an die $postUrl von oben angehängt
|
|
|
|
|
- werden, was auf die gleiche Weise funktioniert wie der $next Parameter eines AuthSub
|
|
|
|
|
- Links. Der einzige Unterschied ist hier das, statt eines einmal zu verwendenden Tokens,
|
|
|
|
|
- ein Status und eine ID Variable in der <acronym>URL</acronym> zurückgegeben werden.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.uploads.browser.example-2">
|
|
|
|
|
- <title>Browser-basierender Upload: Erstellen des HTML Formulars</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-// Platzieren um den Benutzer nach dem Upload umzuleiten
|
|
|
|
|
-$nextUrl = 'http://mysite.com/youtube_uploads';
|
|
|
|
|
-
|
|
|
|
|
-$form = '<form action="'. $postUrl .'?nexturl='. $nextUrl .
|
|
|
|
|
- '" method="post" enctype="multipart/form-data">'.
|
|
|
|
|
- '<input name="file" type="file"/>'.
|
|
|
|
|
- '<input name="token" type="hidden" value="'. $tokenValue .'"/>'.
|
|
|
|
|
- '<input value="Video Daten hochladen" type="submit" />'.
|
|
|
|
|
- '</form>';
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.uploads.status">
|
|
|
|
|
- <title>Den Upload Status prüfen</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Nachdem ein Video hochgeladen wurde, wird es im Upload Feed des authentifizierten
|
|
|
|
|
- Benutzer unmittelbar sichtbar sein. Trotzdem wird es auf der Site nicht öffentlich sein
|
|
|
|
|
- solange es nicht bearbeitet wurde. Videos die ausgeschlossen oder nicht erfolgreich
|
|
|
|
|
- hochgeladen wurden werden auch nur im Upload Feed des authentifizierten Benutzers
|
|
|
|
|
- sichtbar sein. Der folgende Code prüft den Status eines <ulink
|
|
|
|
|
- url="http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_YouTube_VideoEntry.html">Zend_Gdata_YouTube_VideoEntry</ulink>
|
|
|
|
|
- um zu sehen ob er jetzt noch nicht live ist oder ob er nicht akzeptiert wurde.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <example id="zend.gdata.youtube.uploads.status.example">
|
|
|
|
|
- <title>Den Status von Video Uploads checken</title>
|
|
|
|
|
-
|
|
|
|
|
- <programlisting language="php"><![CDATA[
|
|
|
|
|
-try {
|
|
|
|
|
- $control = $videoEntry->getControl();
|
|
|
|
|
-} catch (Zend_Gdata_App_Exception $e) {
|
|
|
|
|
- echo $e->getMessage();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-if ($control instanceof Zend_Gdata_App_Extension_Control) {
|
|
|
|
|
- if ($control->getDraft() != null &&
|
|
|
|
|
- $control->getDraft()->getText() == 'yes') {
|
|
|
|
|
- $state = $videoEntry->getVideoState();
|
|
|
|
|
-
|
|
|
|
|
- if ($state instanceof Zend_Gdata_YouTube_Extension_State) {
|
|
|
|
|
- print 'Upload Status: '
|
|
|
|
|
- . $state->getName()
|
|
|
|
|
- .' '. $state->getText();
|
|
|
|
|
- } else {
|
|
|
|
|
- print 'Die Status Informationen des Videos konnten bis jetzt nicht'
|
|
|
|
|
- . ' empfangen werden. Bitte versuchen Sie es etwas später'
|
|
|
|
|
- . ' nochmals.\n";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-]]></programlisting>
|
|
|
|
|
- </example>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-
|
|
|
|
|
- <sect2 id="zend.gdata.youtube.other">
|
|
|
|
|
- <title>Andere Funktionen</title>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Zusätzlich zur oben beschriebenen Funktionalität, enthält die YouTube
|
|
|
|
|
- <acronym>API</acronym> viele andere Funktionen die es erlauben Video Metadaten zu
|
|
|
|
|
- verändern, Video Einträge zu löschen und den kompletten Bereich an Community Features
|
|
|
|
|
- der Site zu verwenden. Einige der Community Features die durch die
|
|
|
|
|
- <acronym>API</acronym> verändert werden können enthalten: Ratings, Kommentare,
|
|
|
|
|
- Playlisten, Einschreibungen, Benutzer Profile, Kontakte und Nachrichten.
|
|
|
|
|
- </para>
|
|
|
|
|
-
|
|
|
|
|
- <para>
|
|
|
|
|
- Bitte schauen Sie in die komplette Dokumentation die im
|
|
|
|
|
- <ulink url="http://code.google.com/apis/youtube/developers_guide_php.html">PHP
|
|
|
|
|
- Entwickler Guide</ulink> auf code.google.com zu finden ist.
|
|
|
|
|
- </para>
|
|
|
|
|
- </sect2>
|
|
|
|
|
-</sect1>
|
|
|