【異常】微博生成短鏈異常{"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