2014-04-21 2 views
0

RubyMotion에 Sinatra/Warden Remote API와 클라이언트가 있습니다. 초기 등록 (클라이언트에서)을 위해 AFMotion과 함께 인증 토큰 및 사용자 개체를 게시하려면 어떻게합니까?AFMotion Post with Token

내가 지금까지 가지고있는 것보다 다소 적다. 기본적으로 원격 API와 사용자 객체에 토큰을 전달해야합니다.

def register_user(user) 
     @client = AFMotion::Client.build("http://localhost:9393/register") do 
      header "Accept", "application/json" 
      request_serializer: :json 
      response_serializer :json 
     end 
    end 

도움 말? 당신은 더 here을 찾을 수 있습니다

당신은 라인을 변경할 수 있습니다

답변

2

당신이

@client = AFMotion::Client.build("http://localhost:9393/") do 
     header "Accept", "application/json" 
     response_serializer :json 
    end 

같은 것으로 @client 객체를 시작하고 POST 요청을 수행 할 때, 당신은

@client.post('register', { 
     token: 'TOKEN HERE', 
     user: 'USER OBJECT HERE' 
    }) do |result| 
     puts result 
    end 

을 수행 할 수 있습니다 .

+0

대단히 감사합니다. 죄송합니다 - 코드를 설명해 주시겠습니까? 이런 식으로해서는 안됩니다 - http://pastebin.com/74hAwG4Q –

+0

물론 @DaneBalia. 귀하의 코드가 정확합니다. 그러나 제 대답은 전체 코드를 발췌 한 것입니다. 나는 약간의 변화를가한다. 이제 전체 코드를 볼 수 있습니다. – attomos