【问题标题】:Trouble accessing Blogger using UrlFetch使用 UrlFetch 访问 Blogger 时遇到问题
【发布时间】:2013-05-26 07:13:01
【问题描述】:

尝试检索博客但返回错误:

[13-05-25 07:45:42:500 PDT] Exception: Request failed for
https://www.googleapis.com/blogger/v3/users/self/blogs returned code
404. Server response: <!DOCTYPE html> <html lang=en>   <meta charset=utf-8>   <meta name=viewport content="initial-scale=1,
minimum-scale=1, width=device-width">   <title>Error 404 (Not
Found)!!1</title>   <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7%
auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* >
body{background:url(//www.google.com/images/errors/robot.png) 100% 5px
no-repeat;padding-right:205px}p{margin:11px 0
22px;overflow:hidden}ins{color:#777;text-decoration:none}a
img{border:0}@media screen and
(max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}
</style>   <a href=//www.google.com/><img
src=//www.google.com/images/errors/logo_sm.gif alt=Google></a>  
<p><b>404.</b> <ins>That’s an error.</ins>   <p>The requested URL
<code>/blogger/v3/users/self/blogs</code> was not found on this
server.  <ins>That’s all we know.</ins>

这是我的代码:

function retrieveBlog(){
  var access_token ="my acces token";
  var options =
      {
        "headers" : { " Authorization " :  access_token}
      };

  try {

    var result = UrlFetchApp.fetch("https://www.googleapis.com/blogger/v3/users/self/blogs",options);

    Logger.log(result);

  } catch (e) {
    Logger.log(e);
  }
}

你能告诉我哪里错了吗???

【问题讨论】:

    标签: google-apps-script blogger


    【解决方案1】:

    刚刚做了一个快速测试,发现Authorization 标头周围有一个额外的空间。

    试试这一行 -

    "headers" : { "Authorization" : access_token}

    对我来说工作得很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-11
      相关资源
      最近更新 更多