【异常】微博生成短链异常{\"request\":\"/2/short_url/shorten.json\",\"error_code\":\"10014\",\"error\":\"Insufficient app permissions!\"}

匿名 (未验证) 提交于 2019-12-02 23:57:01

一、之前的调用方式

这种方式用了大约有一年时间,之前没有问题,但是2019-8-28号突然不行了,可能是由于微博对该接口的调用做了限制。不允许通过传递source参数的方式进行请求

该接口微博API文档

  /**      * source去新浪微博申请App Key      * @param long_url      * @return      */     @Deprecated     public static String getShortUrl2(String long_url) {         String result = HttpUtils.get(                 "https://api.weibo.com/2/short_url/shorten.json?source="+app_key+"&url_long=" + long_url);          JSONObject jsonObject = JSON.parseObject(result);          JSONObject urls = jsonObject.getJSONArray("urls").getJSONObject(0);         String url_short = urls.getString("url_short");         return url_short;     }

二、修改后的调用方式

该接口微博API文档地址

  /**      * source去新浪微博申请App Key      * @param long_url      * @return      */     public static String getShortUrl(String long_url) {         String result = HttpUtils.get(                 "https://api.t.sina.com.cn/short_url/shorten.json?source="+app_key+"&url_long=" + long_url);          JSONObject jsonObject = JSON.parseArray(result).getJSONObject(0);          String url_short = jsonObject.getString("url_short");         return url_short;     

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!