2016-05-30 6 views
3

まずを使ってiOSアプリでFitBit APIを統合し、私は私がhttps://dev.fitbit.com でアプリをcareatedその後https://www.fitbit.com でアカウントを作成するためにどのようにして、カカオポッドを使用してOAuthSwiftインストールし、私AppDelegateでこのメソッドを実装しは、すべてのスウィフト

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { 
    if (url.host == "oauth-callback") { 
     OAuthSwift.handleOpenURL(url) 
    } 
    return true 
} 

今作成したユーザーアカウントのデータ(名前、手順など)をhttps://www.fitbit.com で作成したいのですがどうすればいいですか?私は検索しましたが、fitbitの統合に関するチュートリアルは見つかりませんでした。私のコードでこの情報をどこで使うのですか? enter image description here データを取得するために何をすべきか、次のステップについて教えてください。

+0

https://omarmetwally.quora.com/Integrating-the-Fitbit-API-in-iOS-apps – 7vikram7

+0

@ 7vikram7私もそれを見ましたが、私はまだそれを取得していません –

答えて

1

FitBitは、クライアントIDと秘密鍵を必要とするOAuth 2.0 APIで動作します。 OAuth 2.0 APIで認証するには、これらのクライアントIDと秘密鍵が必要です。 iOSのFitBitとSwiftの統合に関するブログ記事があります。 は、チェックアウトをしますと https://appengineer.in/2016/04/30/fitbit-aouth-in-ios-app/

EX「のiOSでfitbitを実装する方法」を学ぶ:OAuthのとは対照的に、あなたは基本的な認証でそれを行うことができ

let oauthswift = OAuth2Swift(
     consumerKey: fitbit_clientID, 
     consumerSecret: fitbit_consumer_secret, 
     authorizeUrl: "https://www.fitbit.com/oauth2/authorize", 
     accessTokenUrl: "https://api.fitbit.com/oauth2/token", 
     responseType: "token" 
    ) 
0

任意のチャンスを?私はアプリで実装していたいくつかの自動化された電子メールのためにMailGunにPOSTしようとしても同様の問題がありました。

大規模なHTTP応答で正常に動作するようになりました。 Keys.plistに完全なパスを入れて、自分のコードをgithubにアップロードして、引数のいくつかを変数に分解して、後にプログラムでそれらを設定することができます。

// Email the FBO with desired information 
// Parse our Keys.plist so we can use our path 
var keys: NSDictionary? 

if let path = NSBundle.mainBundle().pathForResource("Keys", ofType: "plist") { 
    keys = NSDictionary(contentsOfFile: path) 
} 

if let dict = keys { 
    // variablize our https path with API key, recipient and message text 
    let mailgunAPIPath = dict["mailgunAPIPath"] as? String 
    let emailRecipient = "[email protected]" 
    let emailMessage = "Testing%20email%20sender%20variables" 

    // Create a session and fill it with our request 
    let session = NSURLSession.sharedSession() 
    let request = NSMutableURLRequest(URL: NSURL(string: mailgunAPIPath! + "from=FBOGo%20Reservation%20%[email protected]<my domain>.com%3E&[email protected]<my domain>.com&to=\(emailRecipient)&subject=A%20New%20Reservation%21&text=\(emailMessage)")!) 

    // POST and report back with any errors and response codes 
    request.HTTPMethod = "POST" 
    let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in 
     if let error = error { 
      print(error) 
     } 

     if let response = response { 
      print("url = \(response.URL!)") 
      print("response = \(response)") 
      let httpResponse = response as! NSHTTPURLResponse 
      print("response code = \(httpResponse.statusCode)") 
     } 
    }) 
    task.resume() 
} 

Mailgunのパス値でmailgunAPIPathと呼ばれる文字列としてKeys.plistにあります。このことができます

https://API:key-<my key>@api.mailgun.net/v3/<my domain>.com/messages? 

願っています!

関連する問題