はじめに
前回に引き続きLive FrameItのSDKを利用した仮想フォトフレームアプリケーションの作成です。今回はユーザーのコレクションを取得してLive FrameItから配信される画像を取得・
図1 仮想フォトフレーム

作成するサンプルアプリケーションのソースコードは,
登録トークンを使用したデイバスIDの取得
前回,
デバイス側でLive IDアカウントによるユーザー認証を行わない代わりに登録トークンという文字列を使用してデバイスをLive FrameItへ登録します。詳しい手順は前回を参照してください。
登録トークンの取得
まずデバイスは,
' (注: まだ不完全な例です)
Dim client = New DeviceSvcSoapClient
Dim manufacturerId = "Virtual Photo Frame"
Dim serialNumber = Now.Ticks.ToString
Dim result = client.GetClaimToken(manufacturerId, serialNumber)
Dim calimToken = result.ClaimToken
GetClaimTokenメソッドの戻り値は,
デイバスIDの取得
ユーザーによる登録トークンの入力が完了すると,
Private Sub RegisterDeviceWithToken()
Dim result As DeviceBindResults
Using client = New DeviceSvcSoapClient
Dim manufacturerId = "Virtual Photo Frame" '製造元の名前
Dim serialNumber = Now.Ticks.ToString ' シリアル番号
' 登録トークンの取得
Dim tokenResult = client.GetClaimToken(manufacturerId, serialNumber)
If tokenResult.ResponseCode <> 0 Then
' (ResponseCode = 1 のとき取得失敗)
Exit Sub
End If
' ユーザーにトークンの提示
MessageBox.Show(tokenResult.ClaimUrl & " へアクセスして登録トークン " & _
tokenResult.ClaimToken & " を設定してください。" & vbCrLf & _
"設定完了後 OK ボタンをクリックしてください。")
' デバイスIDの取得
result = client.DeviceBind(tokenResult.ClaimToken, manufacturerId, serialNumber)
End Using
If result.ResponseCode = 0 Then
' 取得成功 (ResponseCode = 0)
' デバイスIDの保存例 (プロジェクトのプロパティの設定で String型の DeviceId という値を追加しておきます)
My.Settings.DeviceId = result.DeviceId
My.Settings.Save()
End If
End Sub