暗黑3的api - 可以考虑以后做游戏直接用这个api去获取人物和头像,不错的

https://github.com/rnystrom/D3Kit


D3Kit

Warning!

D3Kit is still missing Fallen-Hero, Artisan, and Progression support. Coming soon!

D3Kit is an easy to use layer to communicate with the Diablo 3 API maintained by Blizzard Entertainment. D3Kit handles all of the requests and gives you a simple block style callback system for successes and failures. After successful reqeusts are made, D3Kit parses the JSON response from Blizzard and builds NSObjects for you to use in your apps.

Get Started

Installation

To get started, add D3Kit as a submodule to your project. Make sure to add the submodule from the root of your project.

git submodule add git@github.com:rnystrom/D3Kit.git

Then drag D3Kit.xcodeproj into your project.

D3Kit as subproject

Open the Build Phases of your project. Add D3Kit as a Target Dependency.

Target Dependency

Then add libD3Kit.a to Link Binary With Libraries.

Link Binary with Libraries

In your project, open the Build Settings tab. Search for "User Header Search Paths". Set this value to "${PROJECT_DIR}/D3Kit"(including quotes). Also set "Always Search User Paths" to YES.

Search Paths

Find the “Other Linker Flags” option, and add the value -ObjC (no quotes).

Flags

In your Prefix.pch file add #import <D3Kit/D3Kit.h> and you're done!

Overview

The classes that are populated from Blizzard's Diablo 3 API are:

  • D3Artisan
  • D3Career
  • D3Follower
  • D3Hero
  • D3Item
  • D3Rune
  • D3Skill

Classes have relationships based on the Blizzard Diablo 3 API. Currently the relations are:

  • D3Career has many D3Hero
  • D3Career has many D3Artisan
  • D3Hero has many D3Item
  • D3Hero has many D3Skill
  • D3Hero has many D3Follower
  • D3Item has one D3Rune

The class D3HTTPClient helps retrieve information from Blizzard's Diablo 3 API is a subclass of AFNetworking's AFHTTPClient. All functionality of D3HTTPClient is available. However there are helper methods included with each class to retrieve:

  • Extra information (ie. D3Career call does not fully populate a D3Hero object by nature of the API)
  • Images

Career

To load a career and associated objects pass in an account NSString. This string should be in the format battletag#1234 or elsefailure() will be called. The built-in validation requires a "#" to seperate the account name and number.

[D3Career getCareerForBattletag:account success:^(D3Career *career) {
    // ...
} failure:^(NSError *error) {
    // ...
}];

Hero

When getCareerForBattletag:success: is called each hero for the career is insantiated but not fully loaded because of the way the Blizzard Diablo 3 API is implemented (which is a good thing, as it keeps the response size small). To finish loading a D3Hero object, call:

[hero finishLoadingWithSuccess:^(D3Hero *hero) {
    // ...
} failure:^(NSError *error) {
    // ...
}];

Images

Currently all image requests are instance methods that return a AFImageRequestOperation in the assumption that images will be collected in batches. Ie:

[hero.items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    D3Item *item = (D3Item*)obj;
    AFImageRequestOperation *operation = [correspondingItem requestForItemIconWithImageProcessingBlock:NULL success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
        // ...
    } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
        // ...
    }];
    [mutOperations addObject:operation ];
}];
[[D3HTTPClient sharedClient ] enqueueBatchOfHTTPRequestOperations:mutOperations progressBlock:^(NSUInteger completedOperations, NSUInteger totalOperations){
    // ...
}completionBlock:^(NSArray *operations) {
    // ...
}];

However it should be trivial to add the AFImageRequestOperation to the queue of D3HTTPClient.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值