开放平台API错误信息

微博
{
  "request" : "/statuses/home_timeline.json",
  "error_code" : "20502",
  "error" : "Need you follow uid."
}


微信
{
  "errcode":40013,
  "errmsg":"invalid appid"
}


淘宝
{
  "error_response":{
    "code":50,
    "msg":"Remote service error",
    "sub_code":"isv.invalid-parameter",
    "sub_msg":"非法参数"
  }
}


百度
{
  "status": 0,
  "message": "ok"
}


腾讯
{
  "ret":1002,
  "msg":"请先登录"
}


支付宝
{
  "alipay_trade_query_response":{
    "code":"20000",
    "msg":"Service Currently Unavailable",
    "sub_code":"isp.unknow-error",
    "sub_msg":"系统繁忙"
  }
}


Google
{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "invalidParameter",
        "message": "Invalid string value: 'asdf'. Allowed values: [mostpopular]",
        "locationType": "parameter",
        "location": "chart"
         }
      ],
    "code": 400,
    "message": "Invalid string value: 'asdf'. Allowed values: [mostpopular]"
   }
}


Facebook
{
  "error": {
    "message": "Message describing the error", 
    "type": "OAuthException", 
    "code": 190,
    "error_subcode": 460,
    "error_user_title": "A title",
    "error_user_msg": "A message"
  }
}


Twitter
{
  "errors": [
    {
      "message": "Sorry, that page does not exist",
      "code": 34
    }
  ]
}


Github
{
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "Issue",
      "field": "title",
      "code": "missing_field"
    }
  ]
}


Heroku
{
  "id":       "rate_limit",
  "message":  "Your account reached the API rate limit\nPlease wait a few minutes before making new requests",
  "url":      "https://devcenter.heroku.com/articles/platform-api-reference#rate-limits"
}


几个JSON标准:
http://jsonapi.org/format/#errors
http://labs.omniti.com/labs/jsend
http://docs.oasis-open.org/odata/odata-json-format/v4.0/errata02/os/odata-json-format-v4.0-errata02-os-complete.html#_Toc403940655

字段名:
status、code/type、error/errors、message/description/detail、link/url/rel_url

{
  "status": "error",
  "error": {
     "code": "501",
     "message": "Unsupported functionality",
     "details": [
        "code": 403,
        "message": "",
        "link": "http://www.xxx.com/api/docs/xxx"
     ]
  }
}

猜你喜欢

转载自rensanning.iteye.com/blog/2287478