Ted k’ É assim que tem que ser! Programando em ASP, ASP.NET, PHP, CSS, dentre outras…


26
Feb/09
2


Listar favoritos do YouTube

A Classe:

<%
class YouTube
    private objXML
    private objLista
    private usuario
    private url
    private id, i
    private nome_objeto

    private sub objetosXML()
        set objXML = server.createObject("MSXML2.DOMDocument.3.0")
            objXML.async = false
            objXML.setProperty "ServerHTTPRequest", true
            objXML.validateOnParse = false
            objXML.load(url)
        set objLista = objXML.getElementsByTagName("*")
    end sub

    public sub carregarURL()
        usuario = "nome_do_seu_usuario"
        url = "http://gdata.youtube.com/feeds/api/users/"&usuario&"/favorites"
        call objetosXML()

        for i = 16 to (objLista.length - 1)
            select case (objLista.item(i).nodeName)
                case "id"
                    nome_objeto = objLista.item(i).text
                    id = right(nome_objeto, len(nome_objeto) - instrRev(nome_objeto,"/"))

                    tabela = tabela & "<table width=""494"" border=""0"" cellspacing=""0"" cellpadding=""0"">"
                    tabela = tabela & "<tr><td colspan=""2"">"
                    tabela = tabela & "<object width=225 height=144><param name=movie value=http://www.youtube.com/v/"&id&"></param>"
                    tabela = tabela & "<param name=allowFullScreen value=true></param>"
                    tabela = tabela & "<param name=allowscriptaccess value=always></param>"
                    tabela = tabela & "<embed src=http://www.youtube.com/v/"&id&" type=application/x-shockwave-flash allowscriptaccess=always allowfullscreen=true width=225 height=144></embed>"
                    tabela = tabela & "</object>"
                    tabela = tabela & "</td></tr>"

                case "title"
                    tabela = tabela & "<tr><td width=""92"" valign=""top"" style=""font: 11px Arial;""><strong>TÍTULO:</strong></td>"
                    tabela = tabela & "<td width=""402"" valign=""top"" style=""font: 11px Arial;"">"&objLista.item(i).text&"</td></tr>"

                case "content"
                    tabela = tabela & "<tr><td valign=""top"" style=""text-align: justify; font: 11px Arial;""><strong>DESCRIÇÃO:</strong></td>"
                    tabela = tabela & "<td valign=""top"" style=""font: 11px Arial;"">"&objLista.item(i).text&"</td></tr>"
                    tabela = tabela & "</table><br><br>"
            end select
        next

        response.write(tabela)
    end sub
end class
%>

O HTML

<%@ Language="VBScript" %>
<!--#include file="Default.class.asp"-->
<%
dim yt
set yt = new YouTube
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<%=yt.carregarURL()%>
</body>
</html>

O Resultado:
null


Página 1 de 11



Portfólio Ted k'

Atualize seu Navegador