Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 错误代码34 twitter_oauth 4.9 Gem_Ruby_Ruby On Rails 3_Twitter Oauth - Fatal编程技术网

Ruby 错误代码34 twitter_oauth 4.9 Gem

Ruby 错误代码34 twitter_oauth 4.9 Gem,ruby,ruby-on-rails-3,twitter-oauth,Ruby,Ruby On Rails 3,Twitter Oauth,我们必须将twitter_oauth gem更新为v.0.4.9,以支持twitter新的1.1api。然而,偏爱帖子和跟随用户是行不通的。我在尝试跟踪用户或喜爱的帖子时遇到返回错误,如下所示: {"errors"=>[{"message"=>"Sorry, that page does not exist", "code"=>34}]} 我有一个api_客户端模型,具有以下内容: def follow(id) client.friend(id) end 我的控制器代码

我们必须将twitter_oauth gem更新为v.0.4.9,以支持twitter新的1.1api。然而,偏爱帖子和跟随用户是行不通的。我在尝试跟踪用户或喜爱的帖子时遇到返回错误,如下所示:

{"errors"=>[{"message"=>"Sorry, that page does not exist", "code"=>34}]}
我有一个api_客户端模型,具有以下内容:

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

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

我发现问题出在创业板本身。gem当前的0.4.9版本正在开发中,一些post路径没有反映新的API。我已经提出回购协议,并将我的变更提交给作者审查。我需要更改gem中的favorites.rb和friendships.rb文件。以下是我对gem所做的四项更改:

收藏夹.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
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
友谊。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
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