Giter VIP home page Giter VIP logo

monkeyking's Introduction

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.

monkeyking's People

Contributors

aalenliang avatar cdoky avatar codeeagle avatar damonvvong avatar dismory avatar dorentus avatar fyl00 avatar huangboju avatar iblacksun avatar kaynewbie avatar lanfordcai avatar lexrus avatar limon-o-o avatar liusky avatar madimo avatar nixzhu avatar nuomi1 avatar puttin avatar tgz avatar ufo22940268 avatar wamaker avatar xspyhack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

monkeyking's Issues

OAuth callback 调用两次

未安装新浪微博时采用网页进行认证,OAuth callback 会调用两次,第一次调用 error 不为空,包含 redirect url 信息,第二次 callback dictionary 中包含了有效的 uid 和 accessToken.

ATS support

Is MonkeyKing support HTTPS now? Otherwise use NSAppTransportSecurity to configurate exception domain might be reject after 2017.1.1 .

各个平台的是否可以以插件方式加载

现在所有平台的支持都写在一个文件, 如果有10个分享那就会非常庞大

能否每个平台一个类, 类似UIActivity 让MoneyKing自动加载
这样在扩展的时候MoneyKing不需要动

MonkeyKing not callback

My app can share data to other platforms successfully. However, when coming back to my app, MonkeyKing has performed the programs below.

MonkeyKing.shareMessage(message) { result in
print("result: (result)")
}

The demo hasn't such problems and shareSDK is also O.K. Any idea about this?

QQ 网页授权

如果没有安装 QQ, 无法打开网页授权页面

2015-11-19 14:53:39.589 China[1989:80597] -canOpenURL: failed for URL: "mqqapi://" - error: "(null)"

QQ 国际版 / 日本版支持

今天在尝试使用的时候发现 QQ 分享的 Activity 一直不出现,然后发现是 canOpenURL 失败了。于是下载了一个日本版的 QQ(帐号正好在日区),打开 Info.plist 发现 URL Scheme 都是 mqqi* 或者 QQi*,估计国际版的也一样。

我正在尝试自己用暴力的方式魔改(加一个 QQi 的类型),但是感觉这方式很……不优雅。

请问是否有考虑支持国际版的 QQ 分享?

QQ Web OAuth 失败

当设备上没安装 QQ 时进行 OAuth 授权会弹出 WKWebView,输入密码之后点击授权出现空白页面且回调没有被调用,经检查是 MonkeyKing.swift line 894 造成,注释掉之后正确跳转到 line 903, 能正确得到 access_token 且关闭 WKWebView,不知道基于什么考虑要加上 line 894?

QQ数据线分享是否有计划增加

最近需要用到从APP传递文件到QQ,使用QQ的数据API,使用url:"mqqopensdkdataline://"

用QQ原来的SDK使用方法如下:
@IBAction func sendToQQ(sender: AnyObject) {

    let path = (NSBundle.mainBundle().resourcePath! as NSString).stringByAppendingPathComponent(
        "testZip.zip")
    let data:NSData = NSData(contentsOfFile: path)!

    //发送到QQ
    let file:QQApiFileObject = QQApiFileObject.objectWithData(data, previewImageData: nil, title: "分享标题", description: "分享描述") as! QQApiFileObject


    file.cflag = 16
    let req:SendMessageToQQReq = SendMessageToQQReq(content: file)
    QQApiInterface.sendReq(req)

}

后来打算使用Monkeyking,但一直失败。不知是否有计划,或者能否指教一下。

Typo

MonkeyKing also can post message to Wiebo by webpage.

How to handle Weibo Web OAuth

作者好, 首先感谢开源.
最近试用没有安装微博APP情况下的OAuth授权. 看了代码的基本原理是用一个webview直接打开"https://open.weibo.cn/oauth2/authorize?client_id", 当代理方法要跳转到我们的redirectURI的时候, 关闭webview.
但是, 没有看明白是怎么把授权的结果返回给APP的?包括授权状态,用户ID等信息.

Demo not work

try china demo but I found wechat not working, also return success: false

QQ 分享失败

我项目中集成了 MonkeyKing 0.6.2,进行 QQ 分享失败。能唤起 QQ,但是 QQ 不能弹出分享界面,也没任何错误提示。

我测试 MonkeyKing 的 Demo 是可以的,而且对比了 Demo 我 我自己项目最后生成的 URL Scheme,没发现异常。

swift3.0

2016-09-19 11 20 33

The updated appeared this problem

分享到qq 无法回调

跳回来的url: tencent(appid)://response_from_qq?source=qq&source_scheme=mqqapi&error=0&version=1

在handleOpenURL(:_) 的 UIPasteboard.general.data(forPasteboardType: "com.tencent.tencent(account.appID)")这里 ,执行的结果是nil

How to Get QQ oauth more Info

In Demo, scope, get_user_info But the Block In DIctionary is
{"access_token" = XXXX;
encrytoken = XXXXX;
"expires_in" = XXXX;
msg = sucess;
openid = XXXXX;
"pay_token" = XXXXXX;
ret = 0;
"user_cancelled" = NO;
}
How to get QQ nikename and avatar_url ?

WeChat share among with other Social Networks

Hello.
Congrats about your clean library and the feature that you gave to us!
But I have a question (and not so much of an issue)

I got the following code from your example

func shareButt(sender:UIButton) {



    MonkeyKing.registerAccount(.WeChat(appID: Configs.Wechat.appID, appKey: Configs.Wechat.appKey))

    let shareURL = NSURL(string: "https://www.sintayeah.gr/syntages/")!

    let info = MonkeyKing.Info(
        title: "\(recipeObj[RECIPES_TITLE]!)",
        description: "SintaYEAH!",
        thumbnail: imageFB,
        media: .URL(shareURL)
    )

    let sessionMessage = MonkeyKing.Message.WeChat(.Session(info: info))

    let weChatSessionActivity = AnyActivity(
        type: "com.nixWork.China.WeChat.Session",
        title: NSLocalizedString("WeChat Session", comment: ""),
        image: UIImage(named: "wechat_session")!,
        message: sessionMessage,
        completionHandler: { success in
            print("Session success: \(success)")
        }
    )

    let timelineMessage = MonkeyKing.Message.WeChat(.Timeline(info: info))

    let weChatTimelineActivity = AnyActivity(
        type: "com.nixWork.China.WeChat.Timeline",
        title: NSLocalizedString("WeChat Timeline", comment: ""),
        image: UIImage(named: "wechat_timeline")!,
        message: timelineMessage,
        completionHandler: { success in
            print("Timeline success: \(success)")
        }
    )

    let activityViewController = UIActivityViewController(activityItems: [shareURL], applicationActivities: [weChatSessionActivity, weChatTimelineActivity])

    presentViewController(activityViewController, animated: true, completion: nil)

    }

And my problem is the following.
if i try to share it on facebook it tries to post the link (which it does also for wechat messages and time line but there it loads the thumbnail).

How can i make for Facebook to post the image only? Because now it's trying to post the link and the website doesn't exist yet.
Is there any way to make this happen?
Thanks a lot for your time!

微信登录,用户点击取消之后,回调处理有点问题

微信登录,用户点击取消之后,回调处理有点问题,block没有调起来
回调的url是wx4868b35061f87885://platformId=wechat

handleOpenURL(_:)中跑了这段代码

if let dict = try? PropertyListSerialization.propertyList(from: data, options: PropertyListSerialization.MutabilityOptions(), format: nil) as? [String: Any] {

                guard
                    let account = sharedMonkeyKing.accountSet[.weChat],
                    let info = dict?[account.appID] as? [String: Any],
                    let result = info["result"] as? String,
                    let resultCode = Int(result) else {
                        return false
                }

                let success = (resultCode == 0)
                sharedMonkeyKing.deliverCompletionHandler?(success)

                return success
            }

最后 return success

构建一个微信 order 时候 `signType=SHA1` 参数疑问

我在集成问下微信支付的时候遇到的一点问题,希望得到帮助。
因为项目中并没有用到pay.php中的配置,所已我在客户端自己通过服务端返回的参数够建了一个 MonkeyKing.Order 下面是一些示例代码

// 构建一个 MonkeyKing.Order `signType` 为 `MD5`
let orderString = "weixin://app/\(appID)/pay/?nonceStr=\(nonceStr)&package=Sign=WXPay&partnerId=\(partnerId)&prepayId=\(prepayId)&timeStamp=\(timestamp)&sign=\(sign)&signType=MD5"

let order = MonkeyKing.Order.WeChat(URLString: orderString)

MonkeyKing.payOrder(order) { result in
    print("result: \(result)")
}

然而这段代码 Don't Works

然后我查看 pay.php 的源码,发现在签名时候用的是 MD5 的加密方式 $sign=strtoupper(md5($sign));
但是在返回给客户端的是$iOSLink=sprintf("weixin://app/%s/pay/?nonceStr=%s&package=Sign%%3DWXPay&partnerId=%s&prepayId=%s&timeStamp=%s&sign=%s&signType=SHA1",$APP_ID,$input["noncestr"],$MCH_ID,$input["prepayid"],$input["timestamp"],$sign);
这里最后一个参数却是 Type=SHA1
让我感到很困惑

QQ App Name 错误

当手机上已安装 QQ 进行第三方授权时,跳转到 QQ 的登录界面,显示的 app 名称是 「nixApp」,经检查是 MonkeyKing line 1137 有问题,localizedInfoDictionary 是一个 empty dictionary,而不是 nil.

String format中为啥需要一个while循环?

源代码是这样的

    var monkeyking_qqCallbackName: String {

        var hexString = String(format: "%02llx", (self as NSString).longLongValue)
        while hexString.characters.count < 8 {
            hexString = "0" + hexString
        }

        return "QQ" + hexString
    }
}

如果是这样可以吗

var hexString = String(format: "QQ%08llx", (self as NSString).longLongValue)

为什么不需要处理didFailProvisionalNavigation代理方法

public func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {

    // Pocket OAuth
    if let errorString = (error as NSError).userInfo["NSErrorFailingURLStringKey"] as? String, errorString.hasSuffix(":authorizationFinished") {
        removeWebView(webView, tuples: (nil, nil, nil))
    }
}

这里为什么不需要做removeWebview的处理的?
对WKWebview的这个回调的机制还不是特别清楚. 请教作者?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.