resumable-create-media link - google-docs-api

I'm creating an iOS app that will upload a file to a specific collection in Google Docs. How can I get the resumable-create-media link for that collection?
When I do a get request on the collection as recommended here: https://groups.google.com/forum/?fromgroups#!topic/google-documents-list-api/LOxHfIxVAec
I get the following xml (sadly no resumable-create-media)
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:docs='http://schemas.google.com/docs/2007'
xmlns:batch='http://schemas.google.com/gdata/batch'
xmlns:gd='http://schemas.google.com/g/2005'>
<id>https://docs.google.com/feeds/documents/private/full/folder%3A0B4Xm3k31FF25MXZzbjZvNzhZU00</id>
<published>2012-07-03T14:38:35.068Z</published>
<updated>2012-07-03T14:38:35.068Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/docs/2007#folder' label='folder'/>
<title type='text'>My Collection</title>
<content type='application/atom+xml' src='https://docs.google.com/feeds/folders/private/full/folder%3A0B4Xm3k31FF25MXZzbjZvNzhZU00'/>
<link rel='alternate' type='text/html' href='https://docs.google.com/#folders/folder.0.0B4Xm3k31FF25MXZzbjZvNzhZU00'/>
<link rel='http://schemas.google.com/docs/2007#icon' type='image/png' href='https://ssl.gstatic.com/docs/doclist/images/icon_9_collection_list.png'/>
<link rel='self' type='application/atom+xml' href='https://docs.google.com/feeds/documents/private/full/folder%3A0B4Xm3k31FF25MXZzbjZvNzhZU00'/>
<link rel='edit' type='application/atom+xml' href='https://docs.google.com/feeds/documents/private/full/folder%3A0B4Xm3k31FF25MXZzbjZvNzhZU00/h47320jg'/>
<author><name>xxxx</name>
<email>xxxx#gmail.com</email></author>
<gd:resourceId>folder:0B4Xm3k31FF25MXZzbjZvNzhZU00</gd:resourceId>
<gd:lastModifiedBy><name>stayaway</name><email>xxxx#gmail.com</email></gd:lastModifiedBy>
<gd:quotaBytesUsed>0</gd:quotaBytesUsed>
<docs:writersCanInvite value='true'/>
<gd:feedLink rel='http://schemas.google.com/acl/2007#accessControlList' href='https://docs.google.com/feeds/acl/private/full/folder%3A0B4Xm3k31FF25MXZzbjZvNzhZU00'/>
</entry>
Many Thanks

The Google Drive API has replaced the Documents List API.
A sample Objective-C application that demonstrates use of the Drive API, including uploading and downloading files, is here.

Related

Batch Delete Videos From YouTube Favorites Playlist

I am trying to batch delete videos from the user his YouTube favorites using the YouTube v2 API. (See also https://developers.google.com/youtube/2.0/developers_guide_protocol_batch_processing)
Posting videos to the favorites in batch works nicely; and I can also remove single videos from the favorites without problem (This rules out a problem with authentication).
My request body is as follows, where VIDEOID1 and VIDEOID2 are the <yt:favoriteId>Ids found in their corresponding video xml:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<batch:operation type="delete"/>
<entry><id>VIDEOID1</id></entry>
<entry><id>VIDEOID2</id></entry>
</feed>
This is the response I get back however, where UserID ofcourse is the userID of the user and BatchID is the BatchID given by the service:
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/batch/BATCHID</id>
<updated>2014-01-31T14:50:54.948Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#favorite'/>
<title>Batch Feed</title>
<entry xmlns:batch='http://schemas.google.com/gdata/batch'>
<id>VIDEOID1</id>
<updated>2014-01-31T14:50:54.948Z</updated>
<title>Error</title>
<content>Invalid entry Id/Uri</content>
<batch:status code='400' reason='Invalid entry Id/Uri'/>
</entry>
<entry xmlns:batch='http://schemas.google.com/gdata/batch'>
<id>VIDEOID2</id>
<updated>2014-01-31T14:50:54.949Z</updated>
<title>Error</title>
<content>Invalid entry Id/Uri</content>
<batch:status code='400' reason='Invalid entry Id/Uri'/>
</entry>
</feed>
It states Invalid entry Id/Uri for the videos I try to remove, while when I remove them by singular delete request with the same ID, it works.
Is batch deleting videos from favorites not supported, or am I missing something?
I've got it to work, thanks to this question and answer: Batch deleting videos using YouTube API and HTTpWebRequest
The trick was using the user its userId instead of default, and to use to complete video URL as id.
The batch URL looks like this:
https://gdata.youtube.com/feeds/api/users/USERID/favorites/batch?v=2&alt=json
The request looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<batch:operation type="delete"/>
<entry>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/VIDEOID1?v=2</id>
</entry>
<entry>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/VIDEOID2?v=2</id>
</entry>
</feed>

Insert into Google Merchant data feed using Content API

I'm trying to insert some data into my merchant account data feed using the Content API. Using the code below, I've been given a "POST requests require a Content-length header. That’s all we know." error, but I've set the content length, so I'm really confused.
One theory I have is that it doesn't know where to put these requests, under my merchant account ID, I have two data feeds, and I'm not sure how to set it to enter into a given data feed.
The XML is stolen from here: https://developers.google.com/shopping-content/batch-operations
#feed = '<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
xmlns:g="http://base.google.com/ns/1.0"
xmlns:batch="http://schemas.google.com/gdata/batch">
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:sc="http://schemas.google.com/structuredcontent/2009"
xmlns:scp="http://schemas.google.com/structuredcontent/2009/products"
xmlns:app="http://www.w3.org/2007/app">
<batch:operation type="INSERT"/>
<title>Switch 1</title>
<content type="text">A new item available...</content>
<link rel="alternate" type="text/html" href="http://www.example.com/sku123"/>
<sc:id>SKU123</sc:id>
<sc:content_language>en</sc:content_language>
<sc:target_country>US</sc:target_country>
<scp:google_product_category>Electronics > Networking > Hubs &
Switches</scp:google_product_category>
<scp:condition>new</scp:condition>
<scp:price unit="USD">25</scp:price>
<scp:availability>in stock</scp:availability>
</entry>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:sc="http://schemas.google.com/structuredcontent/2009"
xmlns:scp="http://schemas.google.com/structuredcontent/2009/products"
xmlns:app="http://www.w3.org/2007/app">
<batch:operation type="INSERT"/>
<title>Switch 2</title>
<content type="text">Another item available...</content>
<link rel="alternate" type="text/html" href="http://www.example.com/sku124"/>
<sc:id>SKU124</sc:id>
<sc:content_language>en</sc:content_language>
<sc:target_country>US</sc:target_country>
<scp:google_product_category>Electronics > Networking > Hubs &
Switches</scp:google_product_category>
<scp:condition>new</scp:condition>
<scp:price unit="USD">50</scp:price>
<scp:availability>in stock</scp:availability>
</entry>
</feed>'
http = HTTPClient.new
#output = http.post('https://content.googleapis.com/content/v1/<myMerchantID>/items/products/schema/batch', {},"content"=> #feed, "Content-length"=>#feed.length.to_s, "GData-Version"=> "1", "Authorization" => "AuthSub token=myToken", "Content-Type"=> "application/atom+xml")
Are you Authenticating prior to your post?
https://developers.google.com/shopping-content/getting-started/authentication

cannot get RTMP URL and stream key

I am developing code using the youtube API for live streaming. What I have done
I have registered a project in google and gotten client_id, client_secret, and
developer ID
I have done OAuth 2.0 and gotten the code and exchanged it to AUTH_TOKEN
I can create a live event by posting to domain gdata.youtube.com
with request
/feeds/api/users/default/live/events
with header
Authorization: Bearer AUTH_TOKEN
GData-Version: 2
Content-Type: application/atom+xml
X-GData-Key: key=DEV_ID
with content
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:media='http://search.yahoo.com/mrss/'
xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<title>Test</title>
<summary>Test gogogogo!</summary>
<content type='application/atom+xml'>
<entry>
<yt:private/>
<yt:cdn name='primary'>
<media:content yt:format='18'/>
<media:content yt:format='19'/>
</yt:cdn>
</entry>
</content>
<yt:when start='2013-07-05T22:00:00.000Z'/>
</entry>
This returns HTTP code : 201 and my live event is created, but the returned data
does not include STREAM KEY AND RTMP URL. I need these data to start my live
event automatically.
the return data
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:app='http://www.w3.org/2007/app'
xmlns:media='http://search.yahoo.com/mrss/'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:yt='http://gdata.youtube.com/schemas/2007'
gd:etag='W/"CkEHR347eCp7I2A9WhFQEE0."'>
<id>tag:youtube.com,2008:live:event:XXXXXXXXXXXXXXXXXXXX</id>
<published>2013-07-05T05:03:56.000Z</published>
<updated>2013-07-05T05:03:56.000Z</updated>
<app:edited>2013-07-05T05:03:56.000Z</app:edited>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://gdata.youtube.com/schemas/2007#liveEvent'/>
<title>Test</title>
<summary>Test gogogogo!</summary>
<content type='application/atom+xml'
src='http://gdata.youtube.com/feeds/api/users/XXXXXXX/live/videos/XXXXXXXXX'/>
<link rel='self' type='application/atom+xml'
href='http://gdata.youtube.com/feeds/api/users/XXXXXXXXXXXXXXX/live/events/XXXXXXXXXXXXXXXXXX'/>
<link rel='edit' type='application/atom+xml'
href='http://gdata.youtube.com/feeds/api/users/XXXXXX/live/events/XXXXXXXXXXXXXXXXXXXXXX'/>
<author>
<name>XXXXXX</name>
<uri>http://gdata.youtube.com/feeds/api/users/XXXXXXXXXX</uri>
<yt:userId>XXXXXXXXXXXXX</yt:userId>
</author>
<media:group>
<media:description type='plain'>Test gogogogo!</media:description>
<media:title type='plain'>Test</media:title>
</media:group>
<yt:status>pending</yt:status>
<yt:when start='2013-07-05T22:00:00.000Z'/>
</entry>
If I manually login youtube and click on my create live event, I can see my
stream key and RTMP URL there. And I can use they to start streaming manually
So my problem is: how can I get STREAM KEY and RTMP URL automatically (by API
request)?
----EDIT----
based on https://developers.google.com/youtube/2.0/developers_guide_protocol_managing_live_events
it said that when I success create/adding an event, youtube will returns url like this
<yt:cdn name='primary'>
<media:content yt:format='19' yt:name='yt-live_SpQXZYILnN0_35'
url='rtmp://rtmp1.youtube.com/videolive?...'/>
</yt:cdn>
but in my case, my returned data doesn't include this line
After do some research, I solved it by sending this request
/feeds/api/users/default/live/events?inline=true
and the youtube returns me RTMP server URL
Thanks all

Import custom Atom feed in PowerPivot

Question: I have created a sample xml document containing data conforming to the atom 1.0 schema. When I import the contents of this file (for testing purposes) in PowerPivot, it creates columns for each atom element in each entry, instead of creating a column per content element. Why is this?
Background: A customer wants to import data from a web service which provides a feed that uses a custom XML schema that is not supported by PowerPivot. The service provides the ability for the caller to supply an XSLT template that will be applied to the feed. I am hoping to be able to transform this feed into a valid atom feed thereby allowing the customer to import data into PowerPivot.
Sample atom xml:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<title type="text">My Data Feed</title>
<id>http://temp/feed</id>
<updated>2012-12-13T00:00:00Z</updated>
<entry>
<id>http://temp/feed/1</id>
<title type="text">Title</title>
<author>
<name>Author</name>
</author>
<updated>2012-12-13T00:00:00Z</updated>
<content type="application/xml">
<d:Name>John Smith</d:Name>
<d:Address>Address</d:Address>
<d:Zip>1234</d:Zip>
</content>
</entry>
</feed>
When imported into PowerPivot (selecting "From Data Feeds", clicking "Browse" and pointing out the xml file), it looks like this:
I was excpecting three columns: Name, Address and Zip. If I change "Include Atom Elements" from Auto to False in the connection configuration, no columns are imported.
It seems I was just missing the m:properties element. Final result - also includes examples of null attributes and data types:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<title type="text">My Data Feed</title>
<id>http://temp/feed</id>
<updated>2012-12-13T00:00:00Z</updated>
<entry>
<id>http://temp/feed/1</id>
<title type="text">Title</title>
<author>
<name>Author</name>
</author>
<updated>2012-12-13T00:00:00Z</updated>
<content type="application/xml">
<!-- attributes placed under the properties element -->
<m:properties>
<d:Name>John Smith</d:Name>
<d:Address>Address</d:Address>
<d:Zip m:type="Edm.Int32">1234</d:Zip>
<d:Comment m:null="true" />
</m:properties>
</content>
</entry>
</feed>

Detect if site has an RSS/Atom feed?

I have an URL for the site but not for it's feed(s), which I want to parse.
How to
detect if site has an RSS/Atom feed(s)?
Look for the rel="alternate" type="application/rss+xml" link in the head section of the site's defalut page:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://someurl/feed/" />
<title>Some title</title>
</head>
As mentioned in this question How to check if a site has rss feeds
you need to download the page and check for a rel='alternate'.
You could also have a fallback to regex the page for any mention of a feed.xml or similar, should the first parse fail, if you want to be sure to find any possible link to a RSS/Atom. This would not be as certain to contain the RSS of the actual page, it could be a link to an outside RSS.

Resources