错误代码34 twitter_oauth 4.9宝石

时间:2013-08-06 03:20:11

标签: ruby ruby-on-rails-3 twitter-oauth

我们必须将twitter_oauth gem更新为v.0.4.9以支持Twitter的新1.1 API。但是,收藏帖子和关注用户不起作用。我在尝试关注用户或收藏帖子时收到返回错误,如下所示:

{"errors"=>[{"message"=>"Sorry, that page does not exist", "code"=>34}]}

我有一个api_client模型,其中包含以下内容:

def follow(id)
  client.friend(id)
end

我的控制器代码:

def update
status = if params[:follow] 
  client.follow(params[:id])
elsif params[:follow] == 'false'
  client.follow(params[:id])
end

respond_to do |format|
  format.json do
    if status['screen_name'] == params[:screen_name]
      success = true
      notice = if params[:follow] == 'true'
        "You are now following #{status['screen_name']}"
      else
        "You are no longer following #{status['screen_name']}"
      end
    else
      success = false
      notice = 'Something went wrong. Try again in a couple of seconds.'
    end
    render :json => {:success => success, :message => notice}.to_json
  end
end
end

是否有其他人遇到过这个问题或者可以帮我弄清楚发生了什么?

1 个答案:

答案 0 :(得分:1)

我发现问题是宝石本身。目前0.4.9版本的gem正在进行中,一些帖子路径并未反映新API。我已经分发了回购并将我的更改提交给作者进行审核。我需要的更改是gem中的favorites.rb和friendships.rb文件。以下是我对gem所做的四项更改:

<强> favorites.rb

def favorite(id)
-  post("/favorites/create/#{id}.json")
+  post("/favorites/create.json?id=#{id}")
end

def unfavorite(id)
-  post("/favorites/destroy/#{id}.json")
+  post("/favorites/destroy.json?id=#{id}")
end

<强> friendships.rb

def friend(id)
-  post("/friendships/create/#{id}.json")
+  post("/friendships/create.json?user_id=#{id}&follow=true")
end

def unfriend(id)
-  post("/friendships/destroy/#{id}.json")
+  post("/friendships/destroy.json?user_id=#{id}")
end
相关问题