他ユーザーの属性の読み込み
ユーザーのユーザー名、メールアドレス、もしくは電話番号を指定することで、該当ユーザーの属性にアクセスできます。
読み取り可能なユーザー属性
他ユーザーの属性は読み取り操作のみ可能です。読み取り可能なユーザー属性は、アプリケーションの設定("ユーザー情報の全データを開示" オプション)によって決まります。詳細は ユーザー属性 をご覧ください。
アプリケーション設定の変更方法は ユーザー属性の開示範囲の設定 をご覧ください。
他ユーザー属性の取得
ユーザー名を指定してユーザー属性を取得
ユーザー名指定によるユーザー属性取得の例を以下に挙げます。取得処理を実行するユーザーは、ログインしている必要があります。
Swift:
-
let userName = "user_123456" let found : KiiUser do{ // Find a user by name. found = try KiiUser.find(byUsernameSynchronous: userName) }catch(let error as NSError){ // Handle the error. return }
-
let userName = "user_123456" // Find a user by name. KiiUser.find(byUsername: userName) { (user :KiiUser?, error : Error?) -> Void in if error != nil { // Handle the error. return } }
Objective-C:
-
NSString *username = @"user_123456"; NSError *error = nil; // Find a user by name. KiiUser *found = [KiiUser findUserByUsernameSynchronous:username withError:&error]; if (error != nil) { // Handle the error. return; }
-
NSString *username = @"user_123456"; // Find a user by name. [KiiUser findUserByUsername:username withBlock:^(KiiUser *user, NSError *error) { if (error != nil) { // Handle the error. return; } }];
メールアドレスを指定してユーザー属性を取得
メールアドレス指定によるユーザー属性取得の例を以下に挙げます。指定するメールアドレスは認証済みである必要があります。また、取得処理を実行するユーザーは、ログインしている必要があります。
Swift:
-
let email = "user_123456@example.com" let found : KiiUser do{ // Find a user by email address. found = try KiiUser.find(byEmailSynchronous: email) }catch(let error as NSError){ // Handle the error. return }
-
let email = "user_123456@example.com" // Find a user by email address. KiiUser.find(byEmail: email) { (user :KiiUser?, error : Error?) -> Void in if error != nil { // Handle the error. return } }
Objective-C:
-
NSString *email = @"user_123456@example.com"; NSError *error = nil; // Find a user by email address. KiiUser *found = [KiiUser findUserByEmailSynchronous:email withError:&error]; if (error != nil) { // Handle the error. return; }
-
NSString *email = @"user_123456@example.com"; // Find a user by email address. [KiiUser findUserByEmail:email withBlock:^(KiiUser *user, NSError *error) { if (error != nil) { // Handle the error. return; } }];
電話番号を指定してユーザー属性を取得
電話番号指定によるユーザー属性取得の例を以下に挙げます。指定する電話番号は認証済みである必要があります。また、取得処理を実行するユーザーは、ログインしている必要があります。
なお、電話番号は、+と国コードから始まる国際電話番号で指定してください。
Swift:
-
let phone = "+819012345678" let found : KiiUser do{ // Find a user by phone number. found = try KiiUser.find(byPhoneSynchronous: phone) }catch(let error as NSError){ // Handle the error. return }
-
let phone = "+819012345678" // Find a user by phone number. KiiUser.find(byPhone: phone) { (user :KiiUser?, error : Error?) -> Void in if error != nil { // Handle the error. return } }
Objective-C:
-
NSString *phone = @"+819012345678"; NSError *error = nil; // Find a user by phone number. KiiUser *found = [KiiUser findUserByPhoneSynchronous:phone withError:&error]; if (error != nil) { // Handle the error. return; }
-
NSString *phone = @"+819012345678"; // Find a user by phone number. [KiiUser findUserByPhone:phone withBlock:^(KiiUser *user, NSError *error) { if (error != nil) { // Handle the error. return; } }];
URI 指定でユーザー属性を取得
URI 指定でユーザー属性を取得する例を以下に挙げます。取得処理を実行するユーザーは、ログインしている必要があります。
Swift:
-
let userUri = "Set the URI of an existing user here" // Instantiate a user. let userWithURI = KiiUser(uri: userUri) do{ // Refresh the user. try userWithURI.refreshSynchronous() } catch let error as NSError { // Handle the error. return }
-
let userUri = "Set the URI of an existing user here" // Instantiate a user. let userWithURI = KiiUser(uri: userUri) // Refresh the user. userWithURI.refresh { (user :KiiUser?, error : Error?) -> Void in if error != nil { // Handle the error. return } }
Objective-C:
-
NSString *userURI = @"Set the URI of an existing user here"; // Instantiate a user. KiiUser *userWithURI = [KiiUser userWithURI:userURI]; NSError *error = nil; // Refresh the user. [userWithURI refreshSynchronous:&error]; if (error != nil) { // Handle the error. return; }
-
NSString *userURI = @"Set the URI of an existing user here"; // Instantiate a user. KiiUser *userWithURI = [KiiUser userWithURI:userURI]; // Refresh the user. [userWithURI refreshWithBlock:^(KiiUser *user, NSError *error) { if (error != nil) { // Handle the error. return; } }];
ユーザー ID 指定でユーザー属性を取得
ユーザー ID 指定でユーザー属性を取得する例を以下に挙げます。取得処理を実行するユーザーは、ログインしている必要があります。
Swift:
-
let userID = "Set the ID of an existing user here" // Instantiate a user. let userWithID = KiiUser(uri: userID) do{ // Refresh the user. try userWithID.refreshSynchronous() } catch let error as NSError { // Handle the error. return }
-
let userID = "Set the ID of an existing user here" // Instantiate a user. let userWithID = KiiUser(uri: userID) // Refresh the user. userWithID.refresh { (user :KiiUser?, error : Error?) -> Void in if error != nil { // Handle the error. return } }
Objective-C:
-
NSString *userID = @"Set the ID of an existing user here"; // Instantiate a user. KiiUser *userWithID = [KiiUser userWithID:userID]; NSError *error = nil; // Refresh the user. [userWithID refreshSynchronous:&error]; if (error != nil) { // Handle the error. return; }
-
NSString *userID = @"Set the ID of an existing user here"; // Instantiate a user. KiiUser *userWithID = [KiiUser userWithID:userID]; // Refresh the user. [userWithID refreshWithBlock:^(KiiUser *user, NSError *error) { if (error != nil) { // Handle the error. return; } }];