Tag: api

Soundcloud API支持分页?

我如何使用“linked_pa​​rtitioning = 1”来调用响应中的“next_href”? 我在响应中看到next_href,但我不知道下一步该做什么? :\请帮忙提前谢谢:)

Rails 5 API POST创建params为空

谢谢你看看这个问题。 我正在Rails 5中构建一个API,并且遇到了POST创建请求的问题。 基本上,当我的API获取它们时,我的参数是空的,不知道为什么。 使用Postman发送此JSON对象: { “battle”: { “winner_score”: 300, “loser_score”: 3, “winner_id”: 2, “loser_id”: 1 } } 这是相关的控制器: class Api::V1::BattlesController < ApplicationController protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format.include? 'application/json' } wrap_parameters format: [:json] # POST /battles def create @battle = Battle.new(battle_params) if @battle.save render json: @battle, status: :created, location: @battle else render […]

Youtube API V3插入评论问题

我本质上是使用这里的文档提供的示例代码,但我收到的错误是读取ArgumentError – unknown keyword: snippet 。 还有其他人也有这个问题吗? 我不确定这是否是一个有效的错误,但直觉上他们提供的示例代码应该正常工作? properties = { ‘snippet.parentId’: ‘123’, ‘snippet.textOriginal’: message } resource = create_resource(properties) response = service.insert_comment(‘snippet’, resource)

在请求拥有ruby gem的朋友时Twitter的速率限制

我无法打印出我在Twitter上关注的人员列表。 这段代码工作在250,但现在我跟踪了320人。 失败描述:代码请求超出了twitter的速率限制。 代码会在重置限制所需的时间内hibernate,然后再次尝试。 我认为它的编写方式,它只是不断重试相同的整个可抛弃请求,而不是从它停止的地方开始。 MAX_ATTEMPTS = 3 num_attempts = 0 begin num_attempts += 1 @client.friends.each do |user| puts “#{user.screen_name}” end rescue Twitter::Error::TooManyRequests => error if num_attempts <= MAX_ATTEMPTS sleep error.rate_limit.reset_in retry else raise end end 谢谢!

401 Unauthorized – 在Doorkeeper中请求刷新令牌时授予无效

我在请求刷新令牌方面遇到了麻烦,它一直在返回未经授权的401错误。 我不知道在我提出请求时是否缺少参数。 我添加了刷新令牌的门卫配置。 use_refresh_token 这是请求详细信息: {{root_url}}/oauth/token {“refresh_token”=>”034a74c085219fb8297fd8ef9b59f080918f” “format”=>:json, “controller”=>”/oauth/tokens”, “action”=>”create”, “grant_type”=>”refresh_token”, “client_id”=>””, “client_secret”=> “”} 错误说明: {:error=>:invalid_grant, :error_description=> “The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.”} 顺便说一句,我的所有api请求身份validation都没有让这个刷新令牌失败。 我想知道我在请求参数中缺少什么。

如何使用rails将devise sign_in信息传递到不同的应用程序中

我有3个应用程序需要使用SSO,https和devise进行身份validation相互通信。 我想弄清楚的是如何在一个rails应用程序上执行登录并让链接传递相关的(cookie,会话等),以便外部Web浏览器可以查看信息。 这是3个应用程序的流程。 第一个应用程序是WEB PORTAL。 它向api发送了一堆sso(单点登录)相关字符串。 第二个API_APP应用程序validation信息并将其传递给rails应用程序。 此RAILS_APP应用程序使用devise的“sign_in_and_redirect”帮助程序方法validationapi的信息并在用户中签名 现在这是一个棘手的部分。 如何将RAILS_APP中的信息沿着链路传递回WEB_PORTAL,以便它可以查看Web门户可以查看已登录的用户帐户? 更多信息: 我承认这种架构并不理想,但不幸的是它目前无法改变。 WEB_PORTAL实现并不那么重要,但我认为API_APP需要一些工作。 API_APP将信息格式化为net http请求,如此 uri = URI.parse(MY_RAILS_APP_URI) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri, initheader = {‘Content-Type’ =>’application/json’}) request.body = {“email” => email, “id” => id, “email” => email, “timestamp” => timestamp, “token” => token}.to_json response = http.request(request) location = response.header[‘location’] #if the RAILS_APP […]

替代在Rails的API包装器中使用Thread.current

我开发了一个应用程序,允许我们的客户创建自己的会员保护网站。 然后,我的应用程序连接到外部API服务(客户特定的api_key / api_url),以同步/更新/添加数据到此其他服务。 好吧,我已经为这个其他服务编写了一个API包装器。 但是,我现在看到连接为零的随机丢弃。 以下是我目前使用连接的方式: 我有一个xml / rpc连接类 class ApiConnection attr_accessor :api_url, :api_key, :retry_count def initialize(url, key) @api_url = url @api_key = key @retry_count = 1 end def api_perform(class_type, method, *args) server = XMLRPC::Client.new3({‘host’ => @api_url, ‘path’ => “/api/xmlrpc”, ‘port’ => 443, ‘use_ssl’ => true}) result = server.call(“#{class_type}.#{method}”, @api_key, *args) return result end […]

如何从Skyscanner API post请求中检索Session密钥 – Ruby

在我的应用程序中,我想通过Flight Details获取实时价格,因为我使用了SkyScanner API 。 我在获取数据之前已经阅读了文档,我必须创建实时定价服务会话。 可以通过对api的post请求创建,然后通过使用此SessionKey和apiKey提供SessionKey我可以重新获取数据。 那么如何获得Sessionkey,因为我知道它必须由API服务器提供。 这是我的尝试: require ‘json’ require ‘net/http’ require ‘uri’ post_params = { :apiKey => “[API_KEY]”, :country => “GB”, :currency => “GBP”, :locale => “en-GB”, :adults =>1, :children => 0, :infants => 0, :originplace => ‘11235’, :destinationplace => ‘13554’, :outbounddate => ‘2015-05-19’, :inbounddate => ‘2015-05-26’, :locationschema => ‘Default’, :cabinclass => ‘Economy’, […]

Heroku和Web抓取

我有一个nokigiri web scraper,它发布到我试图发布到heroku的数据库。 我有一个sinatra应用程序前端,我想从数据库中提取。 我是Heroku和Web开发的新手,并不知道处理这类事情的最佳方法。 我是否必须将上传到Web数据库的Web scraper脚本放在sinatra路径下(例如mywebsite.com/scraper)并且只是让它变得模糊不清以至于没有人访问它? 最后,我想让sinatra部分成为从数据库中提取的restapi。 感谢所有输入

用葡萄和回形针上传文件

我正在研究REST API, 尝试上传用户的图片 : 葡萄微框架 回形针gem,但它不起作用,显示此错误 rails版本是3.2.8 No handler found for #<Hashie::Mash filename="user.png" head="Content-Disposition: form-data; name=\"picture\"; filename=\"user.png\"\r\nContent-Type: image/png\r\n" name="picture" tempfile=# type=”image/png”> 我尝试使用控制器测试回形针,但是当我尝试通过葡萄api上传它不起作用我的post标题是multipart / form-data 我的上传代码就是这个 user = User.find(20) user.picture = params[:picture] user.save! 因此,如果无法通过葡萄上传文件,还有其他方法可以通过REST api上传文件吗?