Search This Site

Custom Search

Tuesday, October 26, 2010

[bloggerDev] How upload blogger template to blog?

I can download tamplate by:

$ curl $(CURL_FLAGS) \
--header "Authorization: GoogleLogin auth="`cat login-auth.txt` \
--header "GData-Version: 2" \
http://www.blogger.com/feeds/2689659750631752910/template
>template.atom

Then I make XPath query:

$ xpath template.atom '/feed/entry/content/text()'
Found 1 nodes:
-- NODE --
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html expr:dir='data:blog.languageDirection' xmlns='http://
www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b'
xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://
www.google.com/2005/gml/expr'>
.... .... ....

Then I unescape output:

$ xpath $(WEB_DIR)/template.atom '/feed/entry/content/text()' \
| sed -e 's=&lt;=<=g' -e 's=&gt;=>=g' -e 's=&amp;=\&=g'
>template.xml

Finally I get same as by clicking "Download Full Template" on Blogger
Design==>Edit HTML page.

But I have trouble when try upload template in this way.

'template.atom' contain tag:

<link rel='edit' type='application/atom+xml' href='http://
www.blogger.com/feeds/2689659750631752910/template/default'/>

which seems for updating template accoring to
http://code.google.com/apis/gdata/articles/using_cURL.html#updating-entries

So I firstly try upload 'template.atom' without any changes to it:

$ curl $(CURL_FLAGS) \
--request PUT \
--data-binary @template.atom \
--header "Content-Type: application/atom+xml" \
--header "Authorization: GoogleLogin auth="`cat login-auth.txt` \
--header "GData-Version: 2" \
http://www.blogger.com/feeds/2689659750631752910/template/default

and I get error:

[Line 1, Column 310] Invalid root element, expected (namespace
uri:local name) of (http://www.w3.org/2005/Atom:entry), found (http://
www.w3.org/2005/Atom:feed

If someone interesting in answer for this error I provide first bytes
from 'template.atom':

<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://
www.blogger.com/styles/atom.css" type="text/css"?><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'
gd:etag='W/&quot;Ak8CRHoyeip7ImA9Wx5WFU8.&quot;'><id>tag:blogger.com,
1999:blog-2689659750631752910</
id><updated>2010-09-26T22:21:05.492+03:00</updated><title>Template:
gavenko experiment</title><link rel='http://schemas.google.com/g/
2005#feed
' type='application/atom+xml' href='http://gavenkoa-
exp.blogspot.com/feeds/template'/><link rel='self' type='application/
atom+xml' href='http://www.blogger.com/feeds/2689659750631752910/
template'/><link rel='http://schemas.google.com/g/2005#post'
type='application/atom+xml' href='http://www.blogger.com/feeds/
2689659750631752910/template'/
><author><name>gavenkoa</
name><email>noreply@blogger.com</email></author><generator
version='7.00' uri='http://www.blogger.com'>Blogger</
generator><openSearch:startIndex>1</
openSearch:startIndex><openSearch:itemsPerPage>25</
openSearch:itemsPerPage><entry gd:etag='W/
&quot;Ak8CRHoyeip7ImA9Wx5WFU8.&quot;'><id>tag:blogger.com,
1999:blog-2689659750631752910.layout</
id><published>2009-04-17T22:50:49.850+03:00</
published><updated>2010-09-26T22:21:05.492+03:00</updated><app:edited
xmlns:app='http://www.w3.org/2007/app'>2010-09-26T22:21:05.492+03:00</
app:edited><category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/blogger/2008/kind#template'/
><title>Template: gavenko experiment</title><content>&lt;?xml
version="1.0" encoding="UTF-8" ?&gt;

I search this list for solution but one say that this is impossible
(dated in 2006), another replays are irrelevant.

I think next step is sniffing Firefox session (because of hard to
debug JavaScript from Google??) to understand how Design==>Edit
HTML==>Upload work.

--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To post to this group, send email to bloggerdev@googlegroups.com.
To unsubscribe from this group, send email to bloggerdev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bloggerdev?hl=en.

No comments:

Post a Comment