demo地址:https://download.csdn.net/download/wanmeizty/11286264
抓取淘宝购物车数据以及足迹数据
1,首先接入百川SDK,授权登录,加载购物车,抓取淘宝的接口,然后请求接口获取数据,足迹也是如此
代码片段如下
#import “ViewController.h”
#import <AlibabaAuthSDK/ALBBSDK.h>
#import <AlibcTradeSDK/AlibcTradeSDK.h>
#import <CartAndFootSDK/CartAndFootManager.h>
@interface ViewController ()
@end
@implementation ViewController
– (void)viewDidLoad {
[super viewDidLoad];
UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 40)];
forState:UIControlStateNormal];
;
;
btn.tag = 100;
[self.view addSubview:btn];
UIButton * cartbtn = [[UIButton alloc] initWithFrame:CGRectMake(100, 180, 100, 40)];
[cartbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[cartbtn setTitle:@”购物车” forState:UIControlStateNormal];
[cartbtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
cartbtn.tag = 101;
[self.view addSubview:cartbtn];
// Do any additional setup after loading the view.
}
-(void)click:(UIButton *)btn{
if ([[ALBBSession sharedInstance] isLogin]) {
[self setUpWithTag:btn.tag];
}else{
ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
[albbSDK setAuthOption:NormalAuth];
[albbSDK openDebugLog];
[albbSDK auth:self successCallback:^(ALBBSession *session){
[self setUpWithTag:btn.tag];
} failureCallback:^(ALBBSession *session,NSError *error){
}];
}
}
-(void)setUpWithTag:(NSInteger)tag{
if (tag == 100) {
[CartAndFootManager setUpMyfootBlock:^(NSString * _Nullable json, NSError * _Nonnull error) {
NSLog(@”%@”,json);
}];
}else{
UIWebView * webview = [self.view viewWithTag:6666];
if (webview == nil) {
webview = [[UIWebView alloc] initWithFrame:CGRectZero];
webview.tag = 6666;
}
[CartAndFootManager setUpMycartBlock:^(NSString * _Nullable json, NSError * _Nonnull error) {
NSLog(@”%@”,json);
[webview removeFromSuperview];
}];
id <AlibcTradePage>page = [AlibcTradePageFactory myCartsPage];//打开方式
AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
showParam.openType = AlibcOpenTypeH5;
showParam.linkKey = @”taobao_scheme”;
[self.view addSubview:webview];
[[AlibcTradeSDK sharedInstance].tradeService show:[UIViewController new] webView:webview page:page showParams:showParam taoKeParams:nil trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
} tradeProcessFailedCallback:^(NSError * _Nullable error) {
}];
}
}
@end
demo地址:https://download.csdn.net/download/wanmeizty/11286264
购物车数据获取截图:
足迹数据获取截图:
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/38248.html