我正在将Bitly gem(https://github.com/philnash/bitly)用于Bitly API版本3

将应用程序部署到Heroku时,在缩短URL时出现错误。局部起酥油可以很好地工作。

def get_short_url(url)
    Bitly.use_api_version_3
    bitly = Bitly.new(Settings.bitly.login, Settings.bitly.api_key)
    result = bitly.shorten(url) ----------------- Line 3
    result.short_url
end

上面的代码中的第3行给出了INVALID_URI-'500'错误。

我要缩短的网址是
"https://rs-4615.xyz.com/users/profile_view/20492083"

当我使用bitly.com时,它会缩短。

我无法弄清楚这个问题。有人可以帮忙吗?

Shardul。

最佳答案

回答并接受,以防其他人遇到同一问题。

问题是我的代码中生成的URL没有在URL前面加上“https”协议(protocol),因此失败。

因此,产生的是

rs-4615.xyz.com/users/profile_view/20492083

代替
https://rs-4615.xyz.com/users/profile_view/20492083-这是正确的。

@jstim,感谢您的所有帮助。

10-08 04:40