• Stars
    star
    254
  • Rank 160,264 (Top 4 %)
  • Language
    Objective-C
  • Created almost 13 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Objective-C client library for Douban APIs (OAuth 2.0)

douban-objc-client 介绍

该项目已经废弃

douban-objc-client 是一个 Objective C 实现的 豆瓣 API 客户端。现在仅支持 iOS。

更多信息请查询 豆瓣 API

如何配置?

方法一:项目依赖

*适用于开发过程中可能会修改 douban-objc-client 的源代码的项目

1.DoubanAPIEngine

DoubanAPIEngine.xcodeproj图标拖拽到你的项目文件目录中。

2.设置项目 Building Settings

点击 项目 -> (TARGETS) 图标,在 Build Settings 里找到 Other Linker Flags, 设置为 -all_load, 和 -ObjC

3.设置目标 Building Settings

同上,找到 Header Search Paths,添加

  • ../DoubanAPIEngine/DoubanAPIEngine/OtherSources
  • ../DoubanAPIEngine/DoubanAPIEngine/Sources
  • ${SDK_DIR}/usr/include/libxml2
TIPS :

以上的两个DoubanAPIEngine的目录可以是相对目录也可以是绝对目录,需要自行配置。这里将DoubanAPIEngine目录直接拷贝到了项目目录下。建议如此使用,有助于移植。

4.添加依赖

点击目标(TARGETS)图标,选择 Building Phases,找到 Target Dependencies,添加 DoubanAPIEngine

5.添加所需的 Frameworks

点击目标(TARGETS)图标,选择 Building Phases,在 Link Binary with Libaries 中,加入下列库:

  • libDoubanAPIEngine.a
  • libxml2.dylib
  • libz.dylib
  • CoreGraphics.framework
  • CFNetwork.framework
  • Security.framework
  • SystemConfiguration.framework
  • MobileCoreServices.framework
  • UIKit.framework
  • Foundation.framework
  • SenTestingkit.framework

Tips : 此方法 import 头文件应该使用以下方式:

#import "DOUService.h"

方法二:添加 framework

*适用于不会修改源代码的项目

1.添加 libDoubanAPIEngine.framework

点击目标(TARGETS)图标,选择Building Phases,在Link Binary with Libaries中,加入 libDoubanAPIEngine.framework

2.设置项目 Building Settings

点击 项目 -> (TARGETS) 图标,在 Build Settings 里找到 Other Linker Flags, 设置为 -all_load, 和 -ObjC

3.添加其他库

点击目标(TARGETS)图标,选择Building Phases,在Link Binary with Libaries中,加入

  • libxml2.dylib
  • libz.dylib
  • CoreGraphics.framework
  • CFNetwork.framework
  • Security.framework
  • SystemConfiguration.framework
  • MobileCoreServices.framework
  • UIKit.framework
  • Foundation.framework

Tips : 此方法 import 头文件应该使用以下方式:

#import <libDoubanAPIEngine/DOUService.h>

如何使用?

1.提供 OAuth2 所需参数

DOUService *service = [DOUService sharedInstance];
service.clientId = kAPIKey;
service.clientSecret = kPrivateKey;

2.发起一个异步请求

NSString *subPath = [NSString stringWithFormat:@"/book/subject/%d", bookId];
DOUQuery *query = [[[DOUQuery alloc] initWithSubPath:subPath parameters:nil] autorelease];

query.apiBaseUrlString = service.apiBaseUrlString;
DOUHttpRequest *req = [DOUHttpRequest requestWithQuery:query target:self];

DOUService *service = [DOUService sharedInstance];
[service addRequest:req];

若使用 delegate 方式处理回调,要注意一个问题,某些情况下,request 的 delegate 被 dealloc 后,request 才得到了返回。这时就是一个 已释放的 delegate 来处理回调。 这会造成程序崩溃。处理方法为,在 request 的 delegate (例如某个 UIViewController) 的 dealloc 方法中对 request 发送 clearDelegatesAndCancel 消息,再 release request。

另外一个更为优雅的方法是使用“闭包” (block),DOUHttpRequest 提供了一个方法,可以用闭包来处理回调。由于 request 会自动 retain 闭包。所以,这就避免了使用 delegate 处理回调时可能出现的上述问题。

但, Objective-C 的闭包在 iOS 4.0 及其以上版本才得到支持。

DOUHttpRequest 的闭包处理回调的方法:

+ (DOUHttpRequest *)requestWithQuery:(DOUQuery *)query 
	                 completionBlock:(DOUBasicBlock)completionHandler;

3.异步请求的回调

- (void)requestFinished:(DOUHttpRequest *)req {
	NSError *error = [req error];
	if (!error) {
		DoubanFeedEvent *feed = [[DoubanFeedEvent alloc] initWithData:[req responseData]];
	}
}

- (void)requestFailed:(DOUHttpRequest *)req {
	NSLog(@"error");
}

待办列表

  • 提供更多数据类型的支持,如: 豆邮,日记,收藏
  • 支持 Mac OSX
  • 改进 token 过期时,refresh token 的方式,使其不依赖于本机时间
  • ARC, no-ARC 双模支持

More Repositories

1

DOUAudioStreamer

A Core Audio based streaming audio player for iOS and macOS
Objective-C
2,768
star
2

dpark

Python clone of Spark, a MapReduce alike framework in Python
Python
2,691
star
3

code

[DEPRECATED]Douban CODE
CSS
1,811
star
4

beansdb

Archived, see GoBeansDB instead.
C
870
star
5

douban-client

Python client library for Douban APIs (OAuth 2.0)
Python
744
star
6

rexxar-android

Mobile Hybrid Framework Rexxar Android Container
Java
667
star
7

rexxar-ios

Mobile Hybrid Framework Rexxar iOS Container
Objective-C
578
star
8

FRDIntent

A framework for handle the call between view controllers in iOS
Swift
492
star
9

gobeansdb

Distributed object storage server from Douban Inc.
Go
451
star
10

libmc

Fast and light-weight memcached client for C++ / #python / #golang #libmc
C++
442
star
11

greenify

Make blocking C library work with gevent
C
427
star
12

ynm3k

UI Automation + YUItest driven acceptance tests that can be hooked into Jenkins
JavaScript
410
star
13

paracel

Distributed training framework with parameter server
C++
337
star
14

beanseye

Proxy and monitor for beansdb in Go
Go
233
star
15

rexxar-web

Mobile Hybrid Framework Rexxar Web SDK
JavaScript
206
star
16

Kenshin

Kenshin: A time-series database alternative to Graphite Whisper with 40x improvement in IOPS
Python
206
star
17

tfmesos

Tensorflow in Docker on Mesos #tfmesos #tensorflow #mesos
Python
191
star
18

pymesos

A pure python implementation of Mesos scheduler and executor
Python
163
star
19

brownant

Brownant is a web data extracting framework.
Python
159
star
20

linguist

Language Savant, Python clone of github/linguist.
Python
153
star
21

graph-index

index of Graphite & Diamond
Python
129
star
22

CaoE

Kill all children processes when the parent dies
Python
101
star
23

douban-quixote

Douban's Quixote
Python
82
star
24

douban-utils

Douban's Utils
Python
59
star
25

python-libmemcached

DEPRECATED, use https://github.com/douban/libmc instead. python-libmemcached is a python extention for libmemcached
Python
57
star
26

PyCharlockHolmes

Character encoding detecting library for Python using ICU and libmagic.
Common Lisp
50
star
27

DOUSNSSharing

SNS OAuth 2 binding and sharing
Objective-C
47
star
28

ellen

Ellen is a wrapper of pygit2 and git command.
Python
41
star
29

Polymorph

Transform value of dictionary to property of Objective-C class, by using a `dynamic` like directive.
Objective-C
40
star
30

douban-sqlstore

Douban's MySQL lib.
Python
31
star
31

gpack

GIT Smart HTTP Server Rack Implementation, Python clone of https://github.com/schacon/grack
Python
30
star
32

douban-orz

The Missing Data Manager In Douban
Python
29
star
33

douban-mc

Douban's Memcached lib for python.
Python
27
star
34

charts

Helm charts from douban
Smarty
24
star
35

helpdesk

Yet another helpdesk based on multiple providers
Python
22
star
36

sina

A GIT Smart HTTP Server WSGI Implementation.
Python
21
star
37

sa-tools-core

Handy tools for sysadmin.
Python
18
star
38

graphite-kenshin

A plugin for using graphite-web with the kenshin-based storage backend.
Python
16
star
39

gobeansproxy

A proxy for GoBeansDB
Go
13
star
40

beansdbadmin

GoBeansDB Admin UI
Python
9
star
41

redarrow-rs

A command dispatcher to run executables remotely and safely.
Rust
6
star
42

MTURLProtocol

Multiple NSURLProtocol subclasses alternative solution.
Objective-C
4
star
43

python-libmagic

A wrapper for libmagic with static build.
Python
3
star
44

qiniu-exporter

Go
2
star
45

aliyun-exporter

Go
2
star
46

pyquicklz

C
1
star
47

upyun-exporter

Go
1
star
48

sa-tools-go

go version for sa-tools
Go
1
star