加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Bitly INVALID_URI – ‘500’

发布时间:2020-12-17 04:22:26 所属栏目:百科 来源:网络整理
导读:我正在使用Bitly gem(https:// github.com/philnash/bitly)用于Bitly API Version 3 当应用程序部署到Heroku时缩短URL时出错.局部缩短工作正常. def get_short_url(url) Bitly.use_api_version_3 bitly = Bitly.new(Settings.bitly.login,Settings.bitly.api
我正在使用Bitly gem(https:// github.com/philnash/bitly)用于Bitly API Version 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”协议,因此失败了.

所以,生成的是

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

代替

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

@jstim,谢谢你的帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读