• Stars
    star
    2,753
  • Rank 16,544 (Top 0.4 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

MonkeyKing helps you to post messages to Chinese Social Networks.

MonkeyKing

MonkeyKing helps you post SNS messages to Chinese Social Networks, without their buggy SDKs.

MonkeyKing uses the same analysis process of openshare. We also use some reverse engineering tools such as Hopper Disassembler to unveil several undocumented authentication mechanisms under the hood. It supports sharing Text, URL, Image, Audio, Video, and File to WeChat, QQ, Alipay or Weibo. MonkeyKing can also post messages to Weibo by a web page. (Note: Audio and Video are exclusive to WeChat or QQ, and File is exclusive to QQ Dataline)

MonkeyKing also supports OAuth and Mobile payment via WeChat and Alipay!

Requirements

Swift 5, iOS 9

(For Swift 4.2, use version 1.13.0)

(For Swift 4.1/4.0, use version 1.11.0)

(For Swift 3, use version 1.3.0)

Examples

Share

Example: Share to WeChat (微信):

  1. In your Project Target's Info.plist, set URL Type, LSApplicationQueriesSchemes as follow:

    You should also add weixinULAPI once you enabled Universal Link of your WeChat App.

  2. Register account: // it's not necessary to do it here, but for the sake of convenience

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        MonkeyKing.regsiterAccount(
            .weChat(
                appID: "xxx",
                appKey: "yyy",
                miniAppID: nil,
                universalLink: nil // FIXME: You have to adopt Universal Link otherwise your app name becomes "Unauthorized App"(未验证应用)...
            )
        )
        return true
    }
  3. Append the following code to handle callbacks:

    // AppDelegate.swift
    
    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    //func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { // only for iOS 8
        return MonkeyKing.handleOpenURL(url)
    }

    Remember to handle userActivities if you are using UIScene in your project:

    // SceneDelegate.swift
    
    func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
        MonkeyKing.handleOpenUserActivity(userActivity)
    }
  4. Prepare your message and ask MonkeyKing to deliver it:

    @IBAction func shareURLToWeChatSession(sender: UIButton) {
    
        MonkeyKing.registerAccount(.weChat(appID: "xxx", appKey: "yyy", miniAppID: nil)) // you can do it here (just before deliver)
    
        let message = MonkeyKing.Message.weChat(.session(info: (
            title: "Session",
            description: "Hello Session",
            thumbnail: UIImage(named: "rabbit"),
            media: .url(URL(string: "http://www.apple.com/cn")!)
        )))
    
        MonkeyKing.deliver(message) { success in
            print("shareURLToWeChatSession success: \(success)")
        }
    }

It's done!

OAuth

Example: Weibo OAuth

MonkeyKing.oauth(for: .weibo) { (oauthInfo, response, error) -> Void in
    print("OAuthInfo \(oauthInfo) error \(error)")
    // Now, you can use the token to fetch info.
}

or, WeChat OAuth for code only

MonkeyKing.weChatOAuthForCode { [weak self] (code, error) in
    guard let code = code else {
        return
    }
    // TODO: fetch info with code
}

If the user doesn't have Weibo App installed on their devices then MonkeyKing will use web OAuth:

Pay

Example: Alipay

let order = MonkeyKing.Order.alipay(urlString: urlString, scheme: nil)
MonkeyKing.deliver(order) { result in
    print("result: \(result)")
}

You need to configure pay.php in a remote server. You can find an example of pay.php at the Demo project.


Launch WeChat Mini App

let path = "..."
MonkeyKing.launch(.weChat(.miniApp(username: "gh_XXX", path: path, type: .release))) { result in
    switch result {
    case .success:
        break
    case .failure(let error):
        print("error:", error)
    }
}

Note that username has a gh_ prefix (原始ID).

More

If you like to use UIActivityViewController for sharing then MonkeyKing has AnyActivity which can help you.

Check the demo for more information.

Installation

Carthage

github "nixzhu/MonkeyKing"

CocoaPods

pod 'MonkeyKing'

Swift Package Manager

https://github.com/nixzhu/MonkeyKing

Contributors

Thanks to all the contributors.

Credits

WeChat logos from WeChat-Logo by Ray.

License

MonkeyKing is available under the MIT License. See the LICENSE file for more info.

More Repositories

1

dev-blog

翻译、开发心得或学习笔记
3,938
star
2

Proposer

Make permission request easier.
Swift
855
star
3

Coolie

Coolie(苦力) helps you to create models (& their constructors) from a JSON file.
Swift
507
star
4

KeyboardMan

KeyboardMan helps you to make keyboard animation.
Swift
351
star
5

Sensei

Sensei is a Mac app based on OpenAI API.
Swift
274
star
6

Baby

Create models from a JSON file, even a Baby can do it.
Swift
219
star
7

Wormhole

A more elegant way for message passing between iOS apps and extensions.
Swift
172
star
8

Bible-Assistant

Bible Assistant App
Objective-C
168
star
9

Ruler

Size matters, you need a ruler.
Swift
159
star
10

Navi

Focus on avatar caching.
Swift
115
star
11

AudioBot

AudioBot helps you do audio record & playback.
Swift
38
star
12

Redstone

Redstone has a State Machine
Swift
37
star
13

SharedBaby

Baby's web interface.
Swift
29
star
14

nixBoard

一块简易的围棋棋盘
JavaScript
25
star
15

HelloMou

The translation(Chinese) of Markdown Editor Mou's Hello.md
21
star
16

GentleTouch

Touch yourself, with WATCH.
Swift
19
star
17

Ananda

JSON model decoding based on yyjson.
Swift
16
star
18

AdaptiveChartDemo

Generate chart image from simple data, for WATCH
Swift
15
star
19

computation

Understanding Computation: From Simple Machines to Impossible Programs
Swift
14
star
20

AppClip

Create Web Clip for App.
Swift
14
star
21

rushGo

围棋急速入门,关于围棋的介绍,使对围棋感兴趣的人对围棋的规则有个快速了解。
12
star
22

nixhttpd

简易的http服务器以及测试环境
C
11
star
23

KeypathObserver

KeypathObserver helps you do KVO observing.
Swift
11
star
24

nixGoBoard

在iOS上实现的棋盘应用,可用于在生活中遇到某个围棋爱好者时,将iPad当做棋盘来一局,仅此而已。
Objective-C
11
star
25

SuperPreview

SuperPreview for Image Preview
Swift
8
star
26

AutoReview

AutoReview has a nice logic for show prompt of app review.
Swift
8
star
27

PropertyListenerDemo

Listen, they're changed!
Swift
7
star
28

MentionInUITextViewDemo

Detect mention in UITextView
Swift
7
star
29

TextureDemo

Swift
5
star
30

algorithm-playgrounds

Try some algorithms
Swift
5
star
31

AutoLayoutInUIScrollView

AutoLayout in UIScrollView Demo
Swift
5
star
32

StateMachineDemo

Simple State Machine Demo
Swift
5
star
33

coolie-cli

Coolie's command-line interface
Swift
5
star
34

WorkerBee

WorkerBee is a toolkit
Swift
4
star
35

CenterTwoViewsUseAutoLayout

AutoLayout Tip 1
Objective-C
4
star
36

42

The answer to life, the universe and everything.
3
star
37

NotificationCenterDemo

Swift
3
star
38

sgf2asy

转换sgf格式的围棋棋谱为asy矢量格式的脚本
Python
2
star
39

Girl

A HTML Parser
Swift
2
star
40

nixzhu.github.io

HTML
1
star
41

code-reading

Notes from code reading
1
star