douji3426 2015-11-21 14:51
浏览 6
已采纳

斯堪的纳维亚字符在go-lang go-instagram API绑定中不起作用

Hi I'm trying to wrap my head around what seems to be a problem with multibyte support in this open source library (https://github.com/carbocation/go-instagram/). I am using the code below to retrieve information about the tag blue in swedish. How ever I get an empty array when trying.

fmt.Println("Starting instagram download.")
client := instagram.NewClient(nil)
client.ClientID = "myid"
media, _, _ := client.Tags.RecentMedia("blå", nil)
fmt.Println(media)

I have tried using the api trough the browser and there are several pictures tagged with the tag. I have also tried using the code snippet with tags in English like blue and that returns the latest pictures as well. I would be glad if any one could explain why this might happen. Id like to update the lib so it supports multi-byte but I haven't got the go knowledge required. Is this a go problem or a problem with the library?

Thank you

  • 写回答

1条回答 默认 最新

  • douqian9729 2015-11-21 15:02
    关注

    The problem is in validTagName():

    // Strip out things we know Instagram won't accept. For example, hyphens.
    func validTagName(tagName string) (bool, error) {
        //\W matches any non-word character
        reg, err := regexp.Compile(`\W`)
        if err != nil {
            return false, err
        }
    
        if reg.MatchString(tagName) {
            return false, nil
        }
    
        return true, nil
    }
    

    In Go, \W matches precisely [^0-9A-Za-z_]. This validation check is incorrect.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 WPF RichTextBox格式化大量文本卡顿如何解决
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥15 pip install后修改模块路径,import失败,需要在哪里修改环境变量?
  • ¥15 爬取1-112页所有帖子的标题但是12页后要登录后才能 我使用selenium模拟登录 账号密码输入后 会报错 不知道怎么弄了
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决