jimdoescode/CodeIgniter-YouTube-API-Library

getFormUploadToken woes

Closed this issue · 4 comments

[subtitle]I can't believe my thickness.[/subtitle]
Hey mate, thanks for all the work you've put in to building this library, it helps us all, plus you don't have to deal with bringing Zend in to the equation and bloating the app with unnecesarry code. What I'm trying to get at is an example on how to use getFormUploadToken($metadata); I'm already providing the metadata through a form on my site, I'm also doing all the oauth steps prior to calling this function (youtube_request and youtube_auth), and I still can't figure it out. I'm also looking for a way to ensure that the visitor only uploads to a selected user's channel, IE, like the directUpload has a user in it's args list.

Thanks for any pointers.

Could you give me some clarification? I'm not sure what problem you are experiencing. I tested the getFormUploadToken method and it seemed to work. Though the response was a little odd because it was a mixture of JSON and XML but the upload URL was returned in the XML.

You should be able to upload to whatever account you used to request the upload token with. Meaning if you want to upload to the same account every time you would just call the library with that account information (oauth_token and oauth_token_secret).

I'm going to close this as it's not really an issue but we can continue a dialog in here after the fact.

Shouldn't it provude the response just like the one in the youtube api
documentation? I'm exploding by forward slash and the response provided by
getFormUploadToken doesn't look like a valid xml at all. Just for
reference, the response I'm getting is this:

http://uploads.gdata.youtube.com/action/FormDataUpload/AIwbFASeWpsaiMMKrOADL7rbVXYQwIfC6mnn1ue0XBE4WumucIa4r7qFPkKqWUBR61SgedA82UqQ3SOVOI4rNlamHUuSvXYG8xv6nIhY2mc8-JqwuTSENN0AIwbFAQX-atBIIuyZXTsl2k_l7uM_VKiJxcC7LYMzNWmXkT6AjbNBiQ1NgZIo41P7nmHfl-Eoj9bT7Z1U86H_l5LM-QzXN-NkcoFpEsuXjWXcA4M8Q6z6ZN4zrj8sc3ImImWAsOtO8xtgpu8iy6ifyqjsbuiDO1g0eSg4w5Lf0L8ycW09W8F65sqrXYYHN5ECDHrserQDHgZFbLHQVZ3XWu0p9W9Tdbjzo-4iLdOzhkb37ENH1vUfEr4FTpiM_HKa2GdpmByakqm8Axc7VxU9ZmE5VCBSH2NrVh3rOJ0e9nszDI_GetPwn0Array

while the response in the api examples looks like this:

<response https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_response>
<url https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_url>http://uploads.gdata.youtube.com/action/FormDataUpload/AEF3087AUD
<token https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_token>AEwbFAQEvf3xox...

Is there anything I need to do in order to get a valid xml for parsing?
On Tue, Oct 23, 2012 at 12:20 AM, Jim notifications@github.com wrote:

Could you give me some clarification? I'm not sure what problem you are
experiencing. I tested the getFormUploadToken method and it seemed to work.
Though the response was a little odd because it was a mixture of JSON and
XML but the upload URL was returned in the XML.

You should be able to upload to whatever account you used to request the
upload token with. Meaning if you want to upload to the same account every
time you would just call the library with that account information
(oauth_token and oauth_token_secret).

I'm going to close this as it's not really an issue but we can continue a
dialog in here after the fact.


Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-9681183.

I'm not sure why it provides a mixed response. I didn't specify what the return type should be in my testing so it might be that if you set the return type you will get a specific type. That said it shouldn't be too difficult to parse the response and determine the upload token.

Here is the response I got back.

{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearch/1.1/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","gd$etag":"W/\"DEUEQX06eip7I2A9WhNSEEk.\"","id":{"$t":"tag:youtube.com,2008:user:ggochallenge:inbox"},"updated":{"$t":"2012-10-24T02:36:40.312Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#videoMessage"}],"title":{"$t":"Inbox of ggochallenge"},"logo":{"$t":"http://www.youtube.com/img/pic_youtubelogo_123x63.gif"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/my_messages?folder=inbox&filter=videos"},{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/ggochallenge/inbox?v=2"},{"rel":"http://schemas.google.com/g/2005#batch","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/ggochallenge/inbox/batch?v=2"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/ggochallenge/inbox?alt=json&start-index=1&max-results=25&v=2"},{"rel":"service","type":"application/atomsvc+xml","href":"http://gdata.youtube.com/feeds/api/users/ggochallenge/inbox?alt=atom-service&v=2"}],"author":[{"name":{"$t":"ggochallenge"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/ggochallenge"},"yt$userId":{"$t":"sEFayFKw3E6oMltZemhwMw"}}],"generator":{"$t":"YouTube data API","version":"2.1","uri":"http://gdata.youtube.com"},"openSearch$totalResults":{"$t":0},"openSearch$startIndex":{"$t":1},"openSearch$itemsPerPage":{"$t":25}}}<?xml version='1.0' encoding='UTF-8'?><response><url>http://uploads.gdata.youtube.com/action/FormDataUpload/AIwbFATYJMTs0LhPqqkjEXJu6UerlxLXCtS0rIm_Js1Gh_Xh5CH8CJzjxax53k2hN8N2BjL-r_Os5FLP9wl6xZ9IatsjxAu-Vw</url><token>AIwbFAQDhwducs7wc1dzbkKblVtgdrA6elVC8HgAioIRd-hhgMLDRcNSrQib58M7yRPCZYXalBVPsLQTjws4WVgw5OHy6W7NYUCuMtTHExhXYd1UqveEbZ-_RjJlmnQf386ZIxMPAerZyRNl4vPlU4M8E0whrw2wy6JkS-PTDcJujl67hEy8-ECVYwI6JUjmmza3HXcs4SQAjUyboiMRhj1vE7-Ar-naKobfKQL33DiQil9eHPK1cPn-8W2J28E4LCJUprt62Aid5aNmYeOyH5b7l0XvxYIUXnSpkfQxZ7TN2k1voKdc74rfDE-j8hP65WyAmSFmmxf2</token></response>

After looking at the source of the page on which I'm echoing the response,
I noticed that I'm only getting xml, so I parsed it and voila, it works. I
guess it was a slip on my behalf and I shouldn't of relied solely on echo
and print_r. Thanks for the help, cheers!

On Wed, Oct 24, 2012 at 5:42 AM, Jim notifications@github.com wrote:

I'm not sure why it provides a mixed response. I didn't specify what the
return type should be in my testing so it might be that if you set the
return type you will get a specific type. That said it shouldn't be too
difficult to parse the response and determine the upload token.

Here is the response I got back.

{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearch/1.1/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","gd$etag":"W/\"DEUEQX06eip7I2A9WhNSEEk.\"","id":{"$t":"tag:youtube.com,2008:user:ggochallenge:inbox"},"updated":{"$t":"2012-10-24T02:36:40.312Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#videoMessage"}],"title":{"$t":"Inbox of ggochallenge"},"logo":{"$t":"http://www.youtube.com/img/pic_youtubelogo_123x63.gif"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/my_messages?folder=inbox&filter=videos"},{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/ggochallenge/inbox?v=2"},{"rel":"http://schemas.google.com/g/2005#batch","type":"application/atom+xml","href":"http
://gdata.youtube.com/feeds/api/users/ggochallenge/inbox/batch?v=2"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/ggochallenge/inbox?alt=json&start-index=1&max-results=25&v=2"},{"rel":"service","type":"application/atomsvc+xml","href":"http://gdata.youtube.com/feeds/api/users/ggochallenge/inbox?alt=atom-service&v=2"}],"author":[{"name":{"$t":"ggochallenge"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/ggochallenge"},"yt$userId":{"$t":"sEFayFKw3E6oMltZemhwMw"}}],"generator":{"$t":"YouTube data API","version":"2.1","uri":"http://gdata.youtube.com"},"openSearch$totalResults":{"$t":0},"openSearch$startIndex":{"$t":1},"openSearch$itemsPerPage":{"$t":25}}}http://uploads.gdata.youtube.com/action/FormDataUpload/AIwbFATYJMTs0LhPqqkjEXJu6UerlxLXCtS0rIm_Js1Gh_Xh5CH8CJzjxax53k2hN8N2BjL-r_Os5FLP9wl6xZ9IatsjxAu-VwAIwbFAQDhwd
ucs7wc1dzbkKblVtgdrA6elVC8HgAioIRd-hhgMLDRcNSrQib58M7yRPCZYXalBVPsLQTjws4WVgw5OHy6W7NYUCuMtTHExhXYd1UqveEbZ-_RjJlmnQf386ZIxMPAerZyRNl4vPlU4M8E0whrw2wy6JkS-PTDcJujl67hEy8-ECVYwI6JUjmmza3HXcs4SQAjUyboiMRhj1vE7-Ar-naKobfKQL33DiQil9eHPK1cPn-8W2J28E4LCJUprt62Aid5aNmYeOyH5b7l0XvxYIUXnSpkfQxZ7TN2k1voKdc74rfDE-j8hP65WyAmSFmmxf2


Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-9725916.