实例介绍
【实例简介】
使用大众点评接口收集大众点评中的美食、旅游等团购信息,实现下单、抢购
【实例截图】
【核心代码】
//
// HttpRequestDemoTableViewController.m
// WeiboSDKSrcDemo
//
// Created by DannionQiu on 14-9-23.
// Copyright (c) 2014年 SINA iOS Team. All rights reserved.
//
#import "HttpRequestDemoTableViewController.h"
#import "AppDelegate.h"
#define aTestUserID @"2002619624"
#define anotherTestUserID @"3320390445"
#define aTestStatusID @"3772830615208395"
#define aTestPictureUrl @"http://ww4.sinaimg.cn/mw690/775d8ce8jw8efvrnxafrjj20hs0hst9m.jpg"
@interface HttpRequestDemoTableViewController ()
@end
@implementation HttpRequestDemoTableViewController
void DemoRequestHanlder(WBHttpRequest *httpRequest, id result, NSError *error)
{
NSString *title = nil;
UIAlertView *alert = nil;
if (error)
{
title = NSLocalizedString(@"请求异常", nil);
alert = [[UIAlertView alloc] initWithTitle:title
message:[NSString stringWithFormat:@"%@",error]
delegate:nil
cancelButtonTitle:NSLocalizedString(@"确定", nil)
otherButtonTitles:nil];
}
else
{
title = NSLocalizedString(@"收到网络回调", nil);
alert = [[UIAlertView alloc] initWithTitle:title
message:[NSString stringWithFormat:@"%@",result]
delegate:nil
cancelButtonTitle:NSLocalizedString(@"确定", nil)
otherButtonTitles:nil];
}
[alert show];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 28;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier = [NSString stringWithFormat:@"httpRequestDemoCell"];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
// Configure the cell...
NSInteger row = indexPath.row;
switch (row) {
case WeiboSDKHttpRequestDemoTypeReturn:
cell.textLabel.text = NSLocalizedString(@"关闭", nil);
break;
case WeiboSDKHttpRequestDemoTypeRequestForFriendsListOfUser:
cell.textLabel.text = @"friendships/friends";
break;
case WeiboSDKHttpRequestDemoTypeRequestForFriendsUserIDListOfUser:
cell.textLabel.text = @"friendships/friends/ids";
break;
case WeiboSDKHttpRequestDemoTypeRequestForCommonFriendsListBetweenTwoUser:
cell.textLabel.text = @"friendships/friends/in_common";
break;
case WeiboSDKHttpRequestDemoTypeRequestForBilateralFriendsListOfUser:
cell.textLabel.text = @"friendships/friends/bilateral";
break;
case WeiboSDKHttpRequestDemoTypeRequestForFollowersListOfUser:
cell.textLabel.text = @"friendships/followers";
break;
case WeiboSDKHttpRequestDemoTypeRequestForFollowersUserIDListOfUser:
cell.textLabel.text = @"friendships/followers/ids";
break;
case WeiboSDKHttpRequestDemoTypeRequestForActiveFollowersListOfUser:
cell.textLabel.text = @"friendships/followers/active";
break;
case WeiboSDKHttpRequestDemoTypeRequestForBilateralFollowersListOfUser:
cell.textLabel.text = @"friendships/friends_chain/followers";
break;
case WeiboSDKHttpRequestDemoTypeRequestForFriendshipDetailBetweenTwoUser:
cell.textLabel.text = @"friendships/show";
break;
case WeiboSDKHttpRequestDemoTypeRequestForFollowAUser:
cell.textLabel.text = @"friendships/create";
break;
case WeiboSDKHttpRequestDemoTypeRequestForCancelFollowingAUser:
cell.textLabel.text = @"friendships/destroy";
break;
case WeiboSDKHttpRequestDemoTypeRequestForRemoveFollowerUser:
cell.textLabel.text = @"friendships/followers/destroy";
break;
case WeiboSDKHttpRequestDemoTypeRequestForInviteBilateralFriend:
cell.textLabel.text = @"messages/invite";
break;
case WeiboSDKHttpRequestDemoTypeRequestForUserProfile:
cell.textLabel.text = @"users/show";
break;
case WeiboSDKHttpRequestDemoTypeRequestForStatusIDs:
cell.textLabel.text = @"statuses/user_timeline/ids.json";
break;
case WeiboSDKHttpRequestDemoTypeRequestForRepostAStatus:
cell.textLabel.text = @"statuses/repost";
break;
case WeiboSDKHttpRequestDemoTypeRequestForPostAStatus:
cell.textLabel.text = @"statuses/update";
break;
case WeiboSDKHttpRequestDemoTypeRequestForPostAStatusAndPic:
cell.textLabel.text = @"statuses/upload";
break;
case WeiboSDKHttpRequestDemoTypeRequestForPostAStatusAndPicurl:
cell.textLabel.text = @"statuses/upload_url_text";
break;
case WeiboSDKHttpRequestDemoTypeRequestForRenewAccessToken:
cell.textLabel.text = @"refreshTokenTest";
break;
case WeiboSDKHttpRequestDemoTypeAddGameObject:
cell.textLabel.text = @"game/object/add";
break;
case WeiboSDKHttpRequestDemoTypeAddGameAchievementObject:
cell.textLabel.text = @"game/achievement/add";
break;
case WeiboSDKHttpRequestDemoTypeAddGameAchievementGain:
cell.textLabel.text = @"game/achievement/gain/add";
break;
case WeiboSDKHttpRequestDemoTypeAddGameScoreGain:
cell.textLabel.text = @"game/score/add";
break;
case WeiboSDKHttpRequestDemoTypeRequestForGameScore:
cell.textLabel.text = @"game/score/read_player";
break;
case WeiboSDKHttpRequestDemoTypeRequestForFriendsGameScore:
cell.textLabel.text = @"game/score/read_player_friends";
break;
case WeiboSDKHttpRequestDemoTypeRequestForGameAchievementGain:
cell.textLabel.text = @"game/achievement/user gain";
break;
default:
cell.textLabel.text = @"";
break;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger row = indexPath.row;
UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setSelected:NO];
switch (row) {
case WeiboSDKHttpRequestDemoTypeReturn:
[self dismissViewControllerAnimated:YES completion:^{
}];
break;
case WeiboSDKHttpRequestDemoTypeRequestForFriendsListOfUser:
[self testRequestForFriendsListOfUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForFriendsUserIDListOfUser:
[self testRequestForFriendsUserIDListOfUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForCommonFriendsListBetweenTwoUser:
[self testRequestForCommonFriendsListBetweenTwoUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForBilateralFriendsListOfUser:
[self testRequestForBilateralFriendsListOfUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForFollowersListOfUser:
[self testRequestForFollowersListOfUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForFollowersUserIDListOfUser:
[self testRequestForFollowersUserIDListOfUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForActiveFollowersListOfUser:
[self testRequestForActiveFollowersListOfUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForBilateralFollowersListOfUser:
[self testRequestForBilateralFollowersListOfUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForFriendshipDetailBetweenTwoUser:
[self testRequestForFriendshipDetailBetweenTwoUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForFollowAUser:
[self testRequestForFollowAUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForCancelFollowingAUser:
[self testRequestForCancelFollowingAUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForRemoveFollowerUser:
[self testRequestForRemoveFollowerUser];
break;
case WeiboSDKHttpRequestDemoTypeRequestForInviteBilateralFriend:
[self testRequestForInviteBilateralFriend];
break;
case WeiboSDKHttpRequestDemoTypeRequestForUserProfile:
[self testRequestForUserProfile];
break;
case WeiboSDKHttpRequestDemoTypeRequestForRepostAStatus:
[self testRequestForRepostAStatus];
break;
case WeiboSDKHttpRequestDemoTypeRequestForStatusIDs:
[self testRequestForGetStatusIDs];
break;
case WeiboSDKHttpRequestDemoTypeRequestForPostAStatus:
[self testRequestForPostAStatus];
break;
case WeiboSDKHttpRequestDemoTypeRequestForPostAStatusAndPic:
[self testRequestForPostAStatusAndPic];
break;
case WeiboSDKHttpRequestDemoTypeRequestForPostAStatusAndPicurl:
[self testRequestForPostAStatusAndPicurl];
break;
case WeiboSDKHttpRequestDemoTypeRequestForRenewAccessToken:
[self testRequestForRenewAccessToken];
break;
case WeiboSDKHttpRequestDemoTypeAddGameObject:
[self testAddGameObject];
break;
case WeiboSDKHttpRequestDemoTypeAddGameAchievementObject:
[self testAddGameAchievementObject];
break;
case WeiboSDKHttpRequestDemoTypeAddGameAchievementGain:
[self testAddGameAchievementGain];
break;
case WeiboSDKHttpRequestDemoTypeAddGameScoreGain:
[self testAddGameScoreGain];
break;
case WeiboSDKHttpRequestDemoTypeRequestForGameScore:
[self testRequestForGameScore];
break;
case WeiboSDKHttpRequestDemoTypeRequestForFriendsGameScore:
[self testRequestForFriendsGameScore];
break;
case WeiboSDKHttpRequestDemoTypeRequestForGameAchievementGain:
[self testRequestForGameAchievementGain];
break;
default:
break;
}
}
#pragma mark - Test Method
- (void)testRequestForFriendsListOfUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
//just set extraPara for http request as you want, more paras description can be found on the API website,
//for this API, details are from http://open.weibo.com/wiki/2/friendships/friends/en .
NSMutableDictionary* extraParaDict = [NSMutableDictionary dictionary];
[extraParaDict setObject:@"2" forKey:@"cursor"];
[extraParaDict setObject:@"3" forKey:@"count"];
[WBHttpRequest requestForFriendsListOfUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:extraParaDict queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForFriendsUserIDListOfUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForFriendsUserIDListOfUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForCommonFriendsListBetweenTwoUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForCommonFriendsListBetweenUser:myDelegate.wbCurrentUserID andUser:aTestUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForBilateralFriendsListOfUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForBilateralFriendsListOfUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForFollowersListOfUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForFollowersListOfUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForFollowersUserIDListOfUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForFollowersUserIDListOfUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForActiveFollowersListOfUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForActiveFollowersListOfUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForBilateralFollowersListOfUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForBilateralFollowersListOfUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForFriendshipDetailBetweenTwoUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForFriendshipDetailBetweenTargetUser:aTestUserID andSourceUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForFollowAUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForFollowAUser:aTestUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForCancelFollowingAUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForCancelFollowAUser:anotherTestUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForRemoveFollowerUser
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForRemoveFollowerUser:aTestUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForInviteBilateralFriend
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForInviteBilateralFriend:aTestUserID withAccessToken:myDelegate.wbtoken inviteText:@"这个好玩Test!" inviteUrl:@"http://www.weibo.com/u/2002619624" inviteLogoUrl:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForUserProfile
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForUserProfile:aTestUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForGetStatusIDs
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForStatusIDsFromCurrentUser:myDelegate.wbCurrentUserID withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForRepostAStatus
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForRepostAStatus:aTestStatusID repostText:@"" withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForPostAStatus
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForShareAStatus:@"test" contatinsAPicture:nil orPictureUrl:nil withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForPostAStatusAndPic
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
WBImageObject *image = [WBImageObject object];
image.imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image_1" ofType:@"jpg"]];
[WBHttpRequest requestForShareAStatus:@"test" contatinsAPicture:image orPictureUrl:nil withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForPostAStatusAndPicurl
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForShareAStatus:@"test" contatinsAPicture:nil orPictureUrl:aTestPictureUrl withAccessToken:myDelegate.wbtoken andOtherProperties:nil queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForRenewAccessToken
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
[WBHttpRequest requestForRenewAccessTokenWithRefreshToken:myDelegate.wbRefreshToken queue:nil withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testAddGameObject
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
NSMutableDictionary* extraParaDict = [NSMutableDictionary dictionary];
[extraParaDict setObject:@"646811797" forKey:@"source"];
[extraParaDict setObject:@"2025358001:b110989100001" forKey:@"game_id"];
[extraParaDict setObject:@"game_test" forKey:@"game_name"];
[extraParaDict setObject:@"game_type_test" forKey:@"game_type"];
[extraParaDict setObject:@"image_test" forKey:@"image"];
[extraParaDict setObject:@"description_test" forKey:@"description"];
[extraParaDict setObject:@"creator_uid_test" forKey:@"creator_uid"];
[extraParaDict setObject:@"url_test" forKey:@"url"];
[extraParaDict setObject:@"icon_url_test" forKey:@"icon_url"];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *currentDateStr = [formatter stringFromDate:[NSDate date]];
[extraParaDict setObject:currentDateStr forKey:@"create_time"];
[WBHttpRequest addGameObject:aTestUserID
withAccessToken:myDelegate.wbtoken
andOtherProperties:extraParaDict
queue:nil
withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testAddGameAchievementObject
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
NSMutableDictionary* extraParaDict = [NSMutableDictionary dictionary];
[extraParaDict setObject:@"646811797" forKey:@"source"];
[extraParaDict setObject:@"2025358001:b1109891cec84f1800013" forKey:@"achievement_id"];
[extraParaDict setObject:@"2025358001:b110989100001" forKey:@"game_id"];
[extraParaDict setObject:@"title_test" forKey:@"title"];
[extraParaDict setObject:@"image_test" forKey:@"image"];
[extraParaDict setObject:@"description_test" forKey:@"description"];
[extraParaDict setObject:@"10" forKey:@"game_point"];
[extraParaDict setObject:@"url_test" forKey:@"url"];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *currentDateStr = [formatter stringFromDate:[NSDate date]];
[extraParaDict setObject:currentDateStr forKey:@"create_time"];
[extraParaDict setObject:currentDateStr forKey:@"updated_time"];
[WBHttpRequest addGameAchievementObject:aTestUserID
withAccessToken:myDelegate.wbtoken
andOtherProperties:extraParaDict
queue:nil
withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testAddGameAchievementGain
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
NSMutableDictionary* extraParaDict = [NSMutableDictionary dictionary];
[extraParaDict setObject:@"646811797" forKey:@"source"];
[extraParaDict setObject:@"b1109891cec84f1800013" forKey:@"achievement_id"];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *currentDateStr = [formatter stringFromDate:[NSDate date]];
[extraParaDict setObject:currentDateStr forKey:@"create_time"];
[WBHttpRequest addGameAchievementGain:aTestUserID
withAccessToken:myDelegate.wbtoken
andOtherProperties:extraParaDict
queue:nil
withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testAddGameScoreGain
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
NSMutableDictionary* extraParaDict = [NSMutableDictionary dictionary];
[extraParaDict setObject:@"b110989100001" forKey:@"game_id"];
[extraParaDict setObject:@"646811797" forKey:@"source"];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *currentDateStr = [formatter stringFromDate:[NSDate date]];
[extraParaDict setObject:currentDateStr forKey:@"create_time"];
[extraParaDict setObject:@"10" forKey:@"score"];
[WBHttpRequest addGameScoreGain:aTestUserID
withAccessToken:myDelegate.wbtoken
andOtherProperties:extraParaDict
queue:nil
withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForGameScore
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
NSMutableDictionary* extraParaDict = [NSMutableDictionary dictionary];
[extraParaDict setObject:@"b110989100001" forKey:@"game_id"];
[extraParaDict setObject:@"646811797" forKey:@"source"];
[WBHttpRequest requestForGameScore:aTestUserID
withAccessToken:myDelegate.wbtoken
andOtherProperties:extraParaDict
queue:nil
withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForFriendsGameScore
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
NSMutableDictionary* extraParaDict = [NSMutableDictionary dictionary];
[extraParaDict setObject:@"b110989100001" forKey:@"game_id"];
[extraParaDict setObject:@"646811797" forKey:@"source"];
[WBHttpRequest requestForFriendsGameScore:aTestUserID
withAccessToken:myDelegate.wbtoken
andOtherProperties:extraParaDict
queue:nil
withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
- (void)testRequestForGameAchievementGain
{
AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
NSMutableDictionary* extraParaDict = [NSMutableDictionary dictionary];
[extraParaDict setObject:@"b110989100001" forKey:@"game_id"];
[extraParaDict setObject:@"646811797" forKey:@"source"];
[WBHttpRequest requestForGameAchievementGain:aTestUserID
withAccessToken:myDelegate.wbtoken
andOtherProperties:extraParaDict
queue:nil
withCompletionHandler:^(WBHttpRequest *httpRequest, id result, NSError *error) {
DemoRequestHanlder(httpRequest, result, error);
}];
}
@end
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论