开发者

How do I link to a Blogger post with a post ID?

开发者 https://www.devze.com 2023-01-13 05:42 出处:网络
If I have the ID of a post on a Blogger blog, how do I translate that ID into a URL which links to the post?

If I have the ID of a post on a Blogger blog, how do I translate that ID into a URL which links to the post?

My ultimate goal is to pull posts from my Blogger site to my own site, and then be able to permalink to the actual posts. I'm doing this by parsing the RSS feed for my blog with Javascript. Unfortunately the "link" field in the RSS feed isn't a URL to the blog post... it's a URL to a feed of the comments. I can, however, grab the post ID, which I assumed would be a good way to find the post URL. Any other suggestions appreciated.

Edit: Upon further inspection, I found that the actual post link IS included in the RSS feed. The library I'm using to parse the RSS feed was giving me the wrong link. However, the main question still stands.

Edit: Still can't get a direct link. Here's an example of the links I get for a single entry:

<link rel=​"replies" type=​"application/​atom+xml" href=​"http:​/​/​chadsharpe.blogspot.com/​feeds/​2276618748913180797/​comments/​default" title=​"Post开发者_高级运维 Comments">​
<link rel=​"replies" type=​"text/​html" href=​"https:​/​/​www.blogger.com/​comment.g?blogID=4528045192864780582&postID=2276618748913180797" title=​"2 Comments">​
<link rel=​"edit" type=​"application/​atom+xml" href=​"http:​/​/​www.blogger.com/​feeds/​4528045192864780582/​posts/​default/​2276618748913180797?v=2">​
<link rel=​"self" type=​"application/​atom+xml" href=​"http:​/​/​www.blogger.com/​feeds/​4528045192864780582/​posts/​default/​2276618748913180797?v=2">​
<link rel=​"alternate" type=​"text/​html" href=​"http:​/​/​feedproxy.google.com/​~r/​Funwhenwet/​~3/​PuX-Fqz_xKE/​sharpe-watson-bomb-chris-o-jimmy.html" title=​"Sharpe, Watson, Bomb, Chris O, Jimmy">

The URL I want is:

http://chadsharpe.blogspot.com/2010/08/sharpe-watson-bomb-chris-o-jimmy.html


Reading the spec for post object in blogger rest api v3: https://developers.google.com/resources/api-libraries/documentation/blogger/v3/python/latest/blogger_v3.posts.html

If you are using Python rest API v3 import googleapiclient and google_auth_oauthlib and use get(blogId=*, postId=*) to get the post object the attribute you are looking for is "url" for a published post. But if the post is a draft "url" will hold the base url for the blog.


Well, this may be a lame answer but using the Feedburner feeds I get a direct link to my posts.


What platform are you on Alex? Is using one of the GData APIs a potential path forward for you?

I'm curious about one thing, the link rel="alternate" type="text/html" link for your blog is pointing at feed burner. Do you have your blogger set up to redirect feeds through feedburner? For my test blog my alternate link for text/html links directly to blogspot.com:

<link rel="alternate" type="text/html" href="http://brettmorgan-test-blawg.blogspot.com/2010/10/hello-world.html" title="Hello world"/>


Trying to understand your question a bit more. You can use Feedburner 'buzz-boost' under the 'Publicize' tab to repost a feed of your blog posts on your site.

0

精彩评论

暂无评论...
验证码 换一张
取 消