TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | BSD |
ReleasedLast Release | May 2016 |
Maintained by Dolphin su, Country Code, alexchueh.
Depends on: | |
PIX-cocoa-oauth | ~> 0.0.2 |
OMGHTTPURLRQ | ~> 3.0.2 |
這個 SDK 可以讓你將 PIXNET 的相關資料快速整合進你的 iOS 專案中。 詳細 API 資訊請參考 http://developer.pixnet.pro/
This open-source library allows you to integrate PIXNET into your iOS APP. Learn More detail at http://developer.pixnet.pro/
強烈建議使用 CocoaPods 搜尋並安裝pixnet-ios-sdk
PIXNET iOS SDK 支援 Xcode 5.0,及 iOS 6.0 及之後的版本,且只支援ARC
http://developer.pixnet.pro/#!/apps
申請完成會拿到以下兩把鑰匙
請使用以下的 code 把東西丟寫在您的專案中就可以開始使用了,一般會寫在- application:didFinishLaunchingWithOptions:
裡
#import "PIXNETSDK.h"
[PIXNETSDK setConsumerKey:@"Consumer Key" consumerSecret:@"Consumer Secret"];
請在安裝後在需要用到的 Class 中
#import "PIXNETSDK.h"
就可以開始使用簡易功能。每個 method 都用 block 的方式通知您 query 後的結果,只要 succed 為 YES,result 一定不為 nil,error 必為 nil;相反的,當 succeed 為 NO 時,result 一定是 nil,而 error 一定有東西。
您可以直接使用 error.localizedDescription
告知使用者發生了什麼錯誤,或是您也可以根據error.code
來客製化您的錯誤訊息呈現方式。 error code 的完整說明在這。
這個 SDK 總共分成三層,
取得使用者個人資料:
[[PIXNETSDK new] getUserWithUserName:@"UserName" completion:
^(BOOL succeed, id result, NSError *error) {
if (succeed) {
//做要做的東西
}else{
[[[UIAlertView alloc] initWithTitle:@"Ooops!"
message:error.localizedDescription
delegate:self
cancelButtonTitle:@"確定"
otherButtonTitles:nil, nil] show];
}
}];
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:webView];
[PIXNETSDK loginByOAuth2OpenIDOnlyWithLoginView:webView completion:^(BOOL succeed, id result, NSError *error) {
if (succeed) {
// 使用者登入成功了, 接下來您可以呼叫需要認證才能使用的 method 了
[webView removeFromSuperview];
} else {
// 使用者未登入成功
}
done();
}];
登入後即可使用需認證後才可使用的 Method。
[PIXNETSDK logout];
即可登出。
請參考 CocoaDocs PIXNET-iOS-SDK 說明文件
Email: [email protected] Twitter: @pixnetapi
PIXNET SDK is BSD-licensed. We also provide an additional patent grant.