iOS 抖音插件 抖音直播紅包插件 抖音直播紅包採集 抖音直播紅包自動領取 抖音hook Tweak 源碼

聲明:本博文只是作爲研究學習用途,請不要用於非法、商業用途。


 

自動領取紅包流程分析

1.首先是獲取直播列表(採用定時10秒刷新一次)

2.檢測列表中是否有紅包 -----> 如果有就保存起來

3.開啓定時任務,每秒查詢是否有可領取紅包 -----> 如果有就直接領取


 

目錄

開始代碼

獲取直播列表(10秒/次)

獲取直播列表 Call

檢查直播間是否有紅包 Call  (並保存)

查詢紅包列表是否可領取(1秒/次)

查詢紅包列表是否可領取 Call(並打開)

打開直播紅包 Call


開始代碼

獲取直播列表(10秒/次)

+(void)yyyyyyyyyyyyy
{


    if(![xddCode sharedInstance].isbOpenZDZB){
        [xddCode sharedInstance].isbOpenZDZB = YES;
    }else{
         [UIView xx_makeBottomToast:@"已開啓過了 直播"];
        return;
    }


 //開始子線程
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        while (1==1) {
            NSLog(@"正在自動獲取直播列表%d次",1);
            //獲取直播列表
            dispatch_async(dispatch_get_main_queue(), ^{
                [self getZBlist];//獲取直播列表Call
            });
            
            [NSThread sleepForTimeInterval:10];
        }
    });//end 子線程


}

獲取直播列表 Call

+(void)getZBlist{
//3條
    NSString*url =@"https://webcast.amemv.com/webcast/feed/?cate_id=0&channel_id=21&content_type=0&req_type=0&show_location=0&style=3&sub_channel_id=0&sub_type=live_merge&tab_id=1&type=live&version_code=10.8.0&pass-region=0&js_sdk_version=1.60.0.7&pass-route=0&webcast_sdk_version=1490&app_name=aweme&vid=C8A909E5-93B8-42D9-A5D5-A08837C7A5A7&app_version=10.8.0&language=zh-Hans-CN&device_id=70838725526&channel=App%20Store&mcc_mnc=46001&aid=1128&effect_sdk_version=6.6.0&screen_width=414&openudid=6a25c6406978cbd05928fb03732716a39a0d04e3&cdid=59542D4F-CEB8-46FA-831C-410B2ED0E559&os_api=18&webcast_language=zh&ac=WIFI&os_version=12.3.1&webcast_locale=zh-Hans_CN&device_platform=iphone&build_number=108013&iid=8440917271405&device_type=iPhone%20XS%20Max&is_vcd=1&idfa=6B369BA0-9628-44D0-8491-FD101C292057";
//    12條
            url = @"https://webcast.amemv.com/webcast/feed/?cate_id=0&channel_id=21&content_type=0&req_type=0&show_location=0&style=2&sub_channel_id=0&sub_type=live_merge&tab_id=1&type=live&version_code=10.8.0&pass-region=0&js_sdk_version=1.60.0.7&pass-route=0&webcast_sdk_version=1490&app_name=aweme&vid=CC8E166D-34AB-424A-8EA9-DE0AFC223AF8&app_version=10.8.0&language=zh-Hans-CN&device_id=70854743357&channel=App%20Store&mcc_mnc=46004&aid=1128&effect_sdk_version=6.6.0&screen_width=810&openudid=4ae728e375c1adb5f462d043017363fa981e22d7&cdid=632ED61F-EAE0-47DC-A0B5-0F4951F9A075&os_api=18&webcast_language=zh&ac=WIFI&os_version=13.3&webcast_locale=zh-Hans_CN&device_platform=ipad&build_number=108013&iid=3737984599082238&device_type=iPad7,12&is_vcd=1&idfa=FD639131-0F34-4331-965B-B5B6F67DA31C";
    
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
    @"refresh",@"action",
    @"enter_auto_feed_draw_refresh",@"req_from",
       nil];
//    a    __NSFrozenDictionaryM *   
     [NSClassFromString(@"AWENetworkService") _requestWithURLString:url params:params method:@"GET" needCommonParams:false header:nil modelClass:nil targetAttributes:nil requestSerializer:nil responseSerializer:nil responseBlock:nil enableCache:false completionBlock:^(NSDictionary *m, NSError*err) {
            NSLog(@"獲取直播數據=%@",m);
            if(err){
                 
                NSString*msg = @"獲取直播數據失敗";
                dispatch_async(dispatch_get_main_queue(), ^{
                    [UIView xx_makeBottomToast:msg];
                    [xddTools sharedInstance].isGuanzZhuErr = YES;
                });
            }else{
               NSArray* dataArr =  m[@"data"];

                for (NSDictionary *dic in dataArr) {
                    NSString*id_str =  dic[@"data"][@"id_str"];// @"id_str" : @"6833438820730407680"
                    [self ishongbao:id_str];//檢查直播間是否有紅包
                }

                dispatch_async(dispatch_get_main_queue(), ^{
                    [UIView xx_makeBottomToast:@"獲取直播數據成功"];
                });
                
            }
            
        }];
    
}

檢查直播間是否有紅包 Call  (並保存)

+(void)ishongbao:(NSString*)room_id{
    
    NSString*url = @"";
    
    url = @"https://webcast.amemv.com/webcast/luckybox/box/list/?aid=1128";
    
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
    room_id,@"room_id",
       nil];
    //[0]    (null)    "room_id" : 6833440747308452612
    [NSClassFromString(@"AWENetworkService") _requestWithURLString:url params:params method:@"GET" needCommonParams:false header:nil modelClass:nil targetAttributes:nil requestSerializer:nil responseSerializer:nil responseBlock:nil enableCache:false completionBlock:^(NSDictionary *m, NSError*err) {
             NSLog(@"獲取直播紅包=%@",m);
             if(err){
                  
                 NSString*msg = @"獲取直播紅包失敗";
                 dispatch_async(dispatch_get_main_queue(), ^{
                     [UIView xx_makeBottomToast:msg];
                     [xddTools sharedInstance].isGuanzZhuErr = YES;
                 });
             }else{
                 int hbcount = 0;
                NSArray* dataArr =  m[@"data"];
                long now =  [m[@"extra"][@"now"] longLongValue];
                long nowMy = [[NSString stringWithFormat:@"%ld000",(long)[[NSDate date] timeIntervalSince1970]] longLongValue];
                 //紅包類型
                 //room_id  [3]    (null)    @"business_type" : (long)700    混合
                 for (NSDictionary *dic in dataArr) {
                     NSString*send_time =  dic[@"send_time"];
                     NSString*box_type =  dic[@"box_type"];
                     NSString*box_id =  dic[@"box_id"];
                     NSString*delay_time =  dic[@"delay_time"];
                     
                     NSString*title =  dic[@"title"];
                     NSString*diamond_count =  dic[@"diamond_count"];
                     
//                     [0]    (null)    @"style" : (long)0
//                     [1]    (null)    @"is_official" : NO
//                     [2]    (null)    @"description_list" : @"2 elements"
//                     [3]    (null)    @"business_type" : (long)700
//                     [4]    (null)    @"send_time" : (long)1591036244000
//                     [5]    (null)    @"box_status" : (long)0
//                     [6]    (null)    @"display_duration" : (long)0
//                     [7]    (null)    @"box_id" : (long)6833430664709229319
//                     [8]    (null)    @"flat_duration" : (long)0
//                     [9]    (null)    @"priority" : (long)0
//                     [10]    (null)    @"title" : @"禮物紅包"
//                     [11]    (null)    @"box_type" : (long)1
//                     [12]    (null)    @"delay_time" : (long)300
//                     [13]    (null)    @"unpack_type" : (long)0
//                     [14]    (null)    @"rush_condition" : (long)0
//                     [15]    (null)    @"large" : NO
//                     [16]    (null)    @"user" : 86 key/value pairs
//                     [17]    (null)    @"diamond_count" : (long)20
                     
                     HongbDB * f = [HongbDB creatWithDic:dic room_id:room_id];
                     [f bg_saveOrUpdate];//保存到數據庫,紅包信息
                 }
                 if(dataArr && dataArr.count > 0){
                     NSString*showMsg = [NSString stringWithFormat:@"直播間ID:%@,紅包數:%lu",room_id,(unsigned long)dataArr.count];
                     dispatch_async(dispatch_get_main_queue(), ^{
                         [UIView xx_makeBottomToast:showMsg];
                     });
                     
                 }
                 
             }
             
         }];
    
    
}

查詢紅包列表是否可領取(1秒/次)

+(void)xxxxxxxxx
{
    if(![xddCode sharedInstance].isbOpenZDHB){
        [xddCode sharedInstance].isbOpenZDHB = YES;
    }else{
        [UIView xx_makeBottomToast:@"已開啓過了 紅包"];
        return;
    }
    //開始子線程
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
        while (1==1) {
            NSLog(@"正在自動領取紅包%d次",1);

            //正在自動領取列表
            dispatch_async(dispatch_get_main_queue(), ^{
                [self HBFind];//查詢紅包類別,並自動領取
            });
            
            [NSThread sleepForTimeInterval:1];
        }
    });//end 子線程
    
}

查詢紅包列表是否可領取 Call(並打開)

+(void)HBFind
{
    
    //    [0]    (null)    "send_time" : 1591037464000
    //    [1]    (null)    "box_type" : 1
    //    [2]    (null)    "box_id" : 6833407923390302988
    //    [3]    (null)    "room_id" : "6833369141693713167"
    //    [4]    (null)    "delay_time" : 300

    //查詢所有紅包數據.
    NSArray * finfAlls = [HongbDB bg_findAll:@"HongbDB"];

    
    NSString *timeSp = [NSString stringWithFormat:@"%ld000",(long)[[NSDate date] timeIntervalSince1970]];
    long now = [timeSp longLongValue];
    
    for(HongbDB *fd in finfAlls)
    {
        long send_time = [fd send_time];
        long box_type = [fd box_type];
        long box_id = [fd box_id];
        NSString* room_id = [fd room_id];
        long delay_time = [fd delay_time];
        
        long opentime = send_time + (delay_time*1000);
        
        NSString* title = [fd title];
        
        //是否可領取紅包
        if(now >= opentime ){
            //打開紅包
            [self HBopeng:room_id send_time:send_time box_type:box_type box_id:box_id delay_time:delay_time];
        }
        NSLog(@"%@ 紅包ID:%ld,時間:%ld",title,box_id,send_time);
    }
    
    
}

打開直播紅包 Call

+(void)HBopeng:(NSString*)room_id send_time:(long)send_time box_type:(long)box_type box_id:(long)box_id delay_time:(long)delay_time{

    //    [0]    (null)    "send_time" : 1591037464000
    //    [1]    (null)    "box_type" : 1
    //    [2]    (null)    "box_id" : 6833407923390302988
    //    [3]    (null)    "room_id" : "6833369141693713167"
    //    [4]    (null)    "delay_time" : 300
    
    NSString*url  = @"https://webcast.amemv.com/webcast/luckybox/rush/?version_code=10.8.0&pass-region=0&js_sdk_version=1.60.0.7&pass-route=0&webcast_sdk_version=1490&app_name=aweme&vid=C8A909E5-93B8-42D9-A5D5-A08837C7A5A7&app_version=10.8.0&language=zh-Hans-CN&device_id=70838725526&channel=App%20Store&mcc_mnc=46001&aid=1128&effect_sdk_version=6.6.0&screen_width=414&openudid=6a25c6406978cbd05928fb03732716a39a0d04e3&cdid=59542D4F-CEB8-46FA-831C-410B2ED0E559&os_api=18&webcast_language=zh&ac=WIFI&os_version=12.3.1&webcast_locale=zh-Hans_CN&device_platform=iphone&build_number=108013&iid=8440917271405&device_type=iPhone%20XS%20Max&is_vcd=1&idfa=6B369BA0-9628-44D0-8491-FD101C292057";
    url           = @"https://webcast.amemv.com/webcast/luckybox/rush/?version_code=10.8.0&pass-region=0&js_sdk_version=1.60.0.7&pass-route=0&webcast_sdk_version=1490&app_name=aweme&vid=CC8E166D-34AB-424A-8EA9-DE0AFC223AF8&app_version=10.8.0&language=zh-Hans-CN&device_id=70854743357&channel=App%20Store&mcc_mnc=46004&aid=1128&effect_sdk_version=6.6.0&screen_width=810&openudid=4ae728e375c1adb5f462d043017363fa981e22d7&cdid=632ED61F-EAE0-47DC-A0B5-0F4951F9A075&os_api=18&webcast_language=zh&ac=WIFI&os_version=13.3&webcast_locale=zh-Hans_CN&device_platform=ipad&build_number=108013&iid=3737984599082238&device_type=iPad7,12&is_vcd=1&idfa=FD639131-0F34-4331-965B-B5B6F67DA31C";

    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
    @(send_time),@"send_time",
    @(box_type),@"box_type",
    @(box_id),@"box_id",
    room_id,@"room_id",
    @(delay_time),@"delay_time",
       nil];
    
    [NSClassFromString(@"AWENetworkService") _requestWithURLString:url params:params method:@"POST" needCommonParams:false header:nil modelClass:nil targetAttributes:nil requestSerializer:nil responseSerializer:nil responseBlock:nil enableCache:false completionBlock:^(NSDictionary *m, NSError*err) {
                NSLog(@"打開紅包數據=%@",m);
                if(err){
                     
                    NSString*msg = @"打開紅包失敗";
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [UIView xx_makeBottomToast:msg];
                        [xddTools sharedInstance].isGuanzZhuErr = YES;
                    });
                }else{
                   NSDictionary* dataDic =  m[@"data"];
                    if(dataDic[@"box_type"]){
                        NSString* where = [NSString stringWithFormat:@"where %@=%@",bg_sqlKey(@"box_id"),bg_sqlValue(@(box_id))];
                        [HongbDB bg_delete:@"HongbDB" where:where];//刪除紅包ID數據庫
                    }
//                    [0]    (null)    @"description" : @""
//                    [1]    (null)    @"gift_id" : (long)0
//                    [2]    (null)    @"rush_spam" : (long)0
//                    [3]    (null)    @"rush_too_often" : (long)0
//                    [4]    (null)    @"expired" : NO
//                    [5]    (null)    @"succeed" : NO
//                    [6]    (null)    @"box_type" : (long)1
//                    [7]    (null)    @"text" : @""
//                    [8]    (null)    @"cash_count" : (long)0
//                    [9]    (null)    @"rush_too_much" : (long)0
//                    [10]    (null)    @"gift_name" : @""
//                    [11]    (null)    @"diamond_count" : (long)0
                    
                    
//                    [0]    (null)    @"description" : @""
//                    [1]    (null)    @"gift_id" : (long)0
//                    [2]    (null)    @"rush_spam" : (long)1
//                    [3]    (null)    @"rush_too_often" : (long)0
//                    [4]    (null)    @"expired" : NO
//                    [5]    (null)    @"succeed" : NO
//                    [6]    (null)    @"box_type" : (long)1
//                    [7]    (null)    @"text" : @""
//                    [8]    (null)    @"cash_count" : (long)0
//                    [9]    (null)    @"rush_too_much" : (long)0
//                    [10]    (null)    @"gift_name" : @""
//                    [11]    (null)    @"diamond_count" : (long)0
                    

                }
                
            }];
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章