Method: App42::Social::SocialService#link_user_twitter_account_with_token

Defined in:
lib/social/SocialService.rb

Links the User Twitter access credentials to the App User account.

Parameters:

  • userName
    • Name of the user whose Twitter account to be linked

  • accessToken
    • Request Token retrieved from Twitter after authorizing the App

  • accessTokenSecret
    • Request Token Secret retrieved from Twitter after authorizing the App

Returns:

  • the Social object

Raises:

  • App42Exception



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/social/SocialService.rb', line 271

def (userName, accessToken, accessTokenSecret)
  puts "linkUserTwitterAccount Called "
  puts "Base url #{@base_url}"
  response = nil
  social = Social.new
  social = nil
  util = Util.new
  util.throwExceptionIfNullOrBlank(userName, "userName")
  util.throwExceptionIfNullOrBlank(accessToken, "accessToken")
  util.throwExceptionIfNullOrBlank(accessTokenSecret, "accessTokenSecret")
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    body = {'app42' => {"social"=> {
      "userName" => userName,
      "accessToken" => accessToken,
      "accessTokenSecret" => accessTokenSecret
      }}}.to_json
    puts "Body #{body}"
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("body", body)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/twitter/linkuser/accesscredentials"
    response = connection.post(signature, resource_url, query_params, body)
    social = SocialResponseBuilder.new()
    socialObj = social.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return socialObj
end