123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- //
- // WXApiResponseManager.m
- // SDKSample
- //
- // Created by Jeason on 15/7/14.
- //
- //
- #import "WXApi.h"
- #import "WXApiResponseHandler.h"
- #import "GetMessageFromWXResp+responseWithTextOrMediaMessage.h"
- #import "WXMediaMessage+messageConstruct.h"
- @implementation WXApiResponseHandler
- #pragma mark - Public Methods
- + (BOOL)respText:(NSString *)text {
- GetMessageFromWXResp *resp = [GetMessageFromWXResp responseWithText:text
- OrMediaMessage:nil
- bText:YES];
- return [WXApi sendResp:resp];
- }
- + (BOOL)respImageData:(NSData *)imageData
- MessageExt:(NSString *)messageExt
- Action:(NSString *)action
- ThumbImage:(UIImage *)thumbImage {
- WXImageObject *ext = [WXImageObject object];
- ext.imageData = imageData;
-
- WXMediaMessage *message = [WXMediaMessage messageWithTitle:nil
- Description:nil
- Object:ext
- MessageExt:messageExt
- MessageAction:action
- ThumbImage:thumbImage
- MediaTag:nil];
-
- GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
- OrMediaMessage:message
- bText:NO];
-
- return [WXApi sendResp:resp];
- }
- + (BOOL)respLinkURL:(NSString *)urlString
- Title:(NSString *)title
- Description:(NSString *)description
- ThumbImage:(UIImage *)thumbImage {
- WXWebpageObject *ext = [WXWebpageObject object];
- ext.webpageUrl = urlString;
-
- WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
- Description:description
- Object:ext
- MessageExt:nil
- MessageAction:nil
- ThumbImage:thumbImage
- MediaTag:nil];
-
- GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
- OrMediaMessage:message
- bText:NO];
- return [WXApi sendResp:resp];
- }
- + (BOOL)respMusicURL:(NSString *)musicURL
- dataURL:(NSString *)dataURL
- Title:(NSString *)title
- Description:(NSString *)description
- ThumbImage:(UIImage *)thumbImage {
- WXMediaMessage *message = [WXMediaMessage message];
- message.title = title;
- message.description = description;
- [message setThumbImage:thumbImage];
- WXMusicObject *ext = [WXMusicObject object];
- ext.musicUrl = musicURL;
- ext.musicDataUrl = dataURL;
-
- message.mediaObject = ext;
-
- GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
- OrMediaMessage:message
- bText:NO];
-
- return [WXApi sendResp:resp];
- }
- + (BOOL)respVideoURL:(NSString *)videoURL
- Title:(NSString *)title
- Description:(NSString *)description
- ThumbImage:(UIImage *)thumbImage {
- WXVideoObject *ext = [WXVideoObject object];
- ext.videoUrl = videoURL;
-
- WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
- Description:description
- Object:ext
- MessageExt:nil
- MessageAction:nil
- ThumbImage:thumbImage
- MediaTag:nil];
-
- GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
- OrMediaMessage:message
- bText:NO];
-
- return [WXApi sendResp:resp];
- }
- + (BOOL)respEmotionData:(NSData *)emotionData
- ThumbImage:(UIImage *)thumbImage {
- WXEmoticonObject *ext = [WXEmoticonObject object];
- ext.emoticonData = emotionData;
- WXMediaMessage *message = [WXMediaMessage messageWithTitle:nil
- Description:nil
- Object:ext
- MessageExt:nil
- MessageAction:nil
- ThumbImage:thumbImage
- MediaTag:nil];
-
- GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
- OrMediaMessage:message
- bText:NO];
- return [WXApi sendResp:resp];
- }
- + (BOOL)respFileData:(NSData *)fileData
- fileExtension:(NSString *)extension
- Title:(NSString *)title
- Description:(NSString *)description
- ThumbImage:(UIImage *)thumbImage {
- WXFileObject *ext = [WXFileObject object];
- ext.fileExtension = extension;
- ext.fileData = fileData;
-
- WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
- Description:description
- Object:ext
- MessageExt:nil
- MessageAction:nil
- ThumbImage:thumbImage
- MediaTag:nil];
-
- GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
- OrMediaMessage:message
- bText:NO];
- return [WXApi sendResp:resp];
- }
- + (BOOL)respAppContentData:(NSData *)data
- ExtInfo:(NSString *)info
- ExtURL:(NSString *)url
- Title:(NSString *)title
- Description:(NSString *)description
- MessageExt:(NSString *)messageExt
- MessageAction:(NSString *)action
- ThumbImage:(UIImage *)thumbImage {
- WXAppExtendObject *ext = [WXAppExtendObject object];
- ext.extInfo = info;
- ext.url = url;
- ext.fileData = data;
-
- WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
- Description:description
- Object:ext
- MessageExt:messageExt
- MessageAction:action
- ThumbImage:thumbImage
- MediaTag:nil];
-
- GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
- OrMediaMessage:message
- bText:NO];
- return [WXApi sendResp:resp];
- }
- @end
|