{"id":15030546,"url":"https://github.com/nixzhu/monkeyking","last_synced_at":"2025-05-14T21:04:12.191Z","repository":{"id":1345482,"uuid":"42314826","full_name":"nixzhu/MonkeyKing","owner":"nixzhu","description":"MonkeyKing helps you to post messages to Chinese Social Networks.","archived":false,"fork":false,"pushed_at":"2022-12-08T06:48:36.000Z","size":3150,"stargazers_count":2755,"open_issues_count":18,"forks_count":240,"subscribers_count":68,"default_branch":"master","last_synced_at":"2024-10-29T15:34:16.853Z","etag":null,"topics":["alipay","qq","wechat","weibo"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nixzhu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-11T14:57:31.000Z","updated_at":"2024-10-14T06:34:16.000Z","dependencies_parsed_at":"2022-11-28T10:33:48.062Z","dependency_job_id":null,"html_url":"https://github.com/nixzhu/MonkeyKing","commit_stats":null,"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixzhu%2FMonkeyKing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixzhu%2FMonkeyKing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixzhu%2FMonkeyKing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixzhu%2FMonkeyKing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nixzhu","download_url":"https://codeload.github.com/nixzhu/MonkeyKing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732489,"owners_count":21152852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alipay","qq","wechat","weibo"],"created_at":"2024-09-24T20:13:39.664Z","updated_at":"2025-04-13T15:11:46.734Z","avatar_url":"https://github.com/nixzhu.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp\u003e\n\u003ca href=\"http://cocoadocs.org/docsets/MonkeyKing\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/MonkeyKing.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Carthage/Carthage/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# MonkeyKing\n\nMonkeyKing helps you post SNS messages to Chinese Social Networks, without their buggy SDKs.\n\nMonkeyKing uses the same analysis process of [openshare](https://github.com/100apps/openshare).\nWe also use some reverse engineering tools such as [Hopper Disassembler](https://www.hopperapp.com/) to unveil several undocumented authentication mechanisms under the hood.\nIt supports sharing **Text**, **URL**, **Image**, **Audio**, **Video**, and **File** to **WeChat**, **QQ**, **Alipay** or **Weibo**.\nMonkeyKing 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)\n\nMonkeyKing also supports **OAuth** and **Mobile payment** via WeChat and Alipay!\n\n## Requirements\n\nSwift 5, iOS 9\n\n(For Swift 4.2, use version 1.13.0)\n\n(For Swift 4.1/4.0, use version 1.11.0)\n\n(For Swift 3, use version 1.3.0)\n\n## Examples\n\n### Share\n\nExample: Share to WeChat (微信)：\n\n1. In your Project Target's `Info.plist`, set `URL Type`, `LSApplicationQueriesSchemes` as follow:\n\n    \u003cimg src=\"https://raw.githubusercontent.com/nixzhu/MonkeyKing/master/images/infoList.png\" width=\"600\"\u003e\n    \n    You should also add `weixinULAPI` once you enabled Universal Link of your WeChat App.\n\n2. Register account: // it's not necessary to do it here, but for the sake of convenience\n\n    ```swift\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n        MonkeyKing.regsiterAccount(\n            .weChat(\n                appID: \"xxx\",\n                appKey: \"yyy\",\n                miniAppID: nil,\n                universalLink: nil // FIXME: You have to adopt Universal Link otherwise your app name becomes \"Unauthorized App\"(未验证应用)...\n            )\n        )\n        return true\n    }\n    ```\n\n3. Append the following code to handle callbacks:\n\n    ```swift\n    // AppDelegate.swift\n    \n    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -\u003e Bool {\n    //func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -\u003e Bool { // only for iOS 8\n        return MonkeyKing.handleOpenURL(url)\n    }\n    ```\n    \n    Remember to handle userActivities if you are using `UIScene` in your project:\n    ```swift\n    // SceneDelegate.swift\n    \n    func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {\n        MonkeyKing.handleOpenUserActivity(userActivity)\n    }\n    ```\n\n4. Prepare your message and ask MonkeyKing to deliver it:\n\n    ```swift\n    @IBAction func shareURLToWeChatSession(sender: UIButton) {\n\n        MonkeyKing.registerAccount(.weChat(appID: \"xxx\", appKey: \"yyy\", miniAppID: nil)) // you can do it here (just before deliver)\n\n        let message = MonkeyKing.Message.weChat(.session(info: (\n            title: \"Session\",\n            description: \"Hello Session\",\n            thumbnail: UIImage(named: \"rabbit\"),\n            media: .url(URL(string: \"http://www.apple.com/cn\")!)\n        )))\n\n        MonkeyKing.deliver(message) { success in\n            print(\"shareURLToWeChatSession success: \\(success)\")\n        }\n    }\n    ```\n\nIt's done!\n\n### OAuth\n\nExample: Weibo OAuth\n\n```swift\nMonkeyKing.oauth(for: .weibo) { (oauthInfo, response, error) -\u003e Void in\n    print(\"OAuthInfo \\(oauthInfo) error \\(error)\")\n    // Now, you can use the token to fetch info.\n}\n```\n\nor, WeChat OAuth for code only\n\n``` swift\nMonkeyKing.weChatOAuthForCode { [weak self] (code, error) in\n    guard let code = code else {\n        return\n    }\n    // TODO: fetch info with code\n}\n```\n\nIf the user doesn't have Weibo App installed on their devices then MonkeyKing will use web OAuth:\n\n\u003cimg src=\"https://raw.githubusercontent.com/nixzhu/MonkeyKing/master/images/wbOAuth.png\" width=\"240\"\u003e\n\n### Pay\n\nExample: Alipay\n\n```swift\nlet order = MonkeyKing.Order.alipay(urlString: urlString, scheme: nil)\nMonkeyKing.deliver(order) { result in\n    print(\"result: \\(result)\")\n}\n```\n\u003e You need to configure `pay.php` in a remote server. You can find an example of `pay.php` at the Demo project.\n\n\u003cbr /\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/nixzhu/MonkeyKing/master/images/alipay.gif\" width=\"240\"\u003e\n\n\n### Launch WeChat Mini App\n\n``` swift\nlet path = \"...\"\nMonkeyKing.launch(.weChat(.miniApp(username: \"gh_XXX\", path: path, type: .release))) { result in\n    switch result {\n    case .success:\n        break\n    case .failure(let error):\n        print(\"error:\", error)\n    }\n}\n```\n\nNote that `username` has a `gh_` prefix (原始ID).\n\n### More\n\nIf you like to use `UIActivityViewController` for sharing then MonkeyKing has `AnyActivity` which can help you.\n\n\u003cimg src=\"https://raw.githubusercontent.com/nixzhu/MonkeyKing/master/images/system_share.png\" width=\"240\"\u003e\n\nCheck the demo for more information.\n\n## Installation\n\n### Carthage\n\n```ogdl\ngithub \"nixzhu/MonkeyKing\"\n```\n\n### CocoaPods\n\n```ruby\npod 'MonkeyKing'\n```\n\n### Swift Package Manager\n\n```\nhttps://github.com/nixzhu/MonkeyKing\n```\n\n## Contributors\n\nThanks to all the [contributors](https://github.com/nixzhu/MonkeyKing/graphs/contributors).\n\n## Credits\n\nWeChat logos from [WeChat-Logo](https://github.com/RayPS/WeChat-Logo) by Ray.\n\n## License\n\nMonkeyKing is available under the [MIT License][mitLink]. See the LICENSE file for more info.\n\n[mitLink]:http://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixzhu%2Fmonkeyking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnixzhu%2Fmonkeyking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixzhu%2Fmonkeyking/lists"}