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


一、之前的调用方式

这种方式用了大约有一年时间,之前没有问题,但是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;
    

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM