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 MATLAB代码补全插值
  • ¥15 Typegoose 中如何使用 arrayFilters 筛选并更新深度嵌套的子文档数组信息
  • ¥15 前后端分离的学习疑问?
  • ¥15 stata实证代码答疑
  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的