日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iOS QQ空间 好友分享

發布時間:2024/3/12 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iOS QQ空间 好友分享 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

iOS QQ空間 好友分享

1.進入騰訊開發者平臺,可以查看分享SDK文檔,根據說明按步驟接入

demo演示

- (void)viewDidLoad {

? ? [super viewDidLoad];

? ? // Do any additional setup after loading the view.

? ? self.view.backgroundColor = [UIColor whiteColor];

?? ?

? ? UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

? ? btn.frame = CGRectMake(110, 100, 100, 30);

? ? [btn setTitle:@"QQ空間分享" forState:UIControlStateNormal];

? ? [self.view addSubview:btn];

? ? btn.backgroundColor = [UIColor redColor];

? ? [btn addTarget:self action:@selector(qqZoneShare) forControlEvents:UIControlEventTouchUpInside];

?? ?

? ? UIButton *btnTwo = [UIButton buttonWithType:UIButtonTypeCustom];

? ? btnTwo.frame = CGRectMake(110, 160, 100, 30);

? ? [btnTwo setTitle:@"QQ好友分享" forState:UIControlStateNormal];

? ? [self.view addSubview:btnTwo];

? ? btnTwo.backgroundColor = [UIColor redColor];

? ? [btnTwo addTarget:self action:@selector(qqFriendShare) forControlEvents:UIControlEventTouchUpInside];

}


- (void)qqFriendShare {

? ? NSURL *previewURL = [NSURL URLWithString:@"http://baidu.com"];

? ? NSString *path = [[NSBundle mainBundle] bundlePath];

? ? NSString *name = [NSString stringWithFormat:@"iconname.png"];

? ? NSString *finalPath = [path stringByAppendingPathComponent:name];

? ? NSData *previeImgData = [NSData dataWithContentsOfFile:finalPath];

? ? QQApiNewsObject *imgObj = [QQApiNewsObject objectWithURL:previewURL title:@"分享內容的title" description:@"本寶寶是內容的描述" previewImageData:previeImgData];

? ? [imgObj setCflag:kQQAPICtrlFlagQQShare];

?? ?

?? ?

? ? SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:imgObj];

? ? QQApiSendResultCode sent = [QQApiInterface sendReq:req];

? ? [self handleSendResult:sent];

}


- (void)qqZoneShare {

?? ?

#pragma mark--分享純文本 success

//? ? QQApiTextObject *txtObj = [QQApiTextObject objectWithText:@"分享內容的text"];

#pragma mark--分享news success

//? ? NSURL *previewURL = [NSURL URLWithString:@"http://v.youku.com/v_show/id_XMTQ3OTM4MzMxMg==_ev_3.html?from=y1.3-idx-uhome-1519-20887.205805-205902.3-1"];

? ? NSURL *previewURL = [NSURL URLWithString:@"http://baidu.com"];

? ? NSString *path = [[NSBundle mainBundle] bundlePath];

? ? NSString *name = [NSString stringWithFormat:@"iconname.png"];

? ? NSString *finalPath = [path stringByAppendingPathComponent:name];

? ? NSData *previeImgData = [NSData dataWithContentsOfFile:finalPath];

? ? QQApiNewsObject *imgObj = [QQApiNewsObject objectWithURL:previewURL title:@"分享內容的title" description:@"本寶寶是內容的描述" previewImageData:previeImgData];

? ? [imgObj setCflag:kQQAPICtrlFlagQZoneShareOnStart];

? ?

?? ?

? ? SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:imgObj];

? ? QQApiSendResultCode sent = [QQApiInterface SendReqToQZone:req];

? ? [self handleSendResult:sent];

}



- (void)handleSendResult:(QQApiSendResultCode)sendResult {

? ? switch (sendResult) {

? ? ? ? case EQQAPIAPPNOTREGISTED:

? ? ? ? {

? ? ? ? ? ? UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"App未注冊" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];

? ? ? ? ? ? [msgbox show];

? ? ? ? ? ? break;

? ? ? ? }

? ? ? ? case EQQAPIMESSAGECONTENTINVALID:

? ? ? ? case EQQAPIMESSAGECONTENTNULL:

? ? ? ? case EQQAPIMESSAGETYPEINVALID:

? ? ? ? {

? ? ? ? ? ? UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"發送參數錯誤" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];

? ? ? ? ? ? [msgbox show];

?? ? ? ? ? ?

? ? ? ? ? ? break;

? ? ? ? }

? ? ? ? case EQQAPIQQNOTINSTALLED:

? ? ? ? {

? ? ? ? ? ? UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"未安裝手Q" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];

? ? ? ? ? ? [msgbox show];

? ? ? ? ? ? break;

? ? ? ? }

? ? ? ? case EQQAPIQQNOTSUPPORTAPI:

? ? ? ? {

? ? ? ? ? ? UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"API接口不支持" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];

? ? ? ? ? ? [msgbox show];

?? ? ? ? ? ?

? ? ? ? ? ? break;

? ? ? ? }

? ? ? ? case EQQAPISENDFAILD:

? ? ? ? {

? ? ? ? ? ? UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"發送失敗" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];

? ? ? ? ? ? [msgbox show];

?? ? ? ? ? ?

? ? ? ? ? ? break;

? ? ? ? }


? ? ? ? default:

? ? ? ? ? ? break;

? ? }

}


總結

以上是生活随笔為你收集整理的iOS QQ空间 好友分享的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。