Objective-C的 GitHub API 客戶端
octokit.objc 是 Objective-C的 GitHub API 客戶端。
OctoKit 是 Cocoa and Cocoa Touch 框架,用來與 GitHub API, 進行交互,可使用 AFNetworking,Mantle 和 ReactiveCocoa
發出請求:
為了與API進行交互,您必須實例化一個 OCTClient. 這里有兩種可創建無需驗證客戶端的方法。
-
-initWithServer:這是實例化一個客戶端的最基本的方法. 它可以接收一個 OCTServer, 用來判斷是否要連接到 GitHub.com 或者GitHub Enterprise 接口。
-
+unauthenticatedClientWithUser:這種方法和上面的相似, 但是它允許你設置一個 active 用戶, 這需要有特定的請求。
采用第二種方法,我們可以獲得更多操作。創建一個連接到 GitHub.com 的客戶端。
OCTUser *user = [OCTUser userWithRawLogin:username server:OCTServer.dotComServer]; OCTClient *client = [OCTClient unauthenticatedClientWithUser:user];
獲得客戶端后,我們便可以開始抓取數據。在OCTClient 的每個請求方法會返回一個ReactiveCocoa信號這類似于一個future or promise
// Prepares a request that will load all of the user's repositories, represented // by `OCTRepository` objects. // Note that the request is not actually _sent_ until you use one of the // -subscribe… methods below. RACSignal *request = [client fetchUserRepositories];
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!