• 【异常】微博生成短链异常{"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;
        
  • 相关阅读:
    一个Bean属性拷贝的工具类
    java Integer parseInt()
    sql 预编译 in
    显著性图谱的评价
    如何优雅的在MFC中使用cvSetMouseCallback?
    为MFC界面添加一个Log Window
    最大流算法统计
    2014年秋 求职总结
    图论的常用算法
    常用的排序算法
  • 原文地址:https://www.cnblogs.com/756623607-zhang/p/11441190.html
Copyright © 2020-2023  润新知