-
-
Save nwg/1436022 to your computer and use it in GitHub Desktop.
SocializeSDK iOS Code Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// invoke the call | |
[socialize authenticateWithApiKey:@"YourApiKey" apiSecret:@"YourApiSecret"]; | |
#pragma mark SocializeServiceDelegate implementation | |
// implement the delegate | |
-(void)didAuthenticate{ | |
NSLog(@"Authenticated"); | |
} | |
// if the authentication fails the following method is called | |
-(void)service:(SocializeService*)service didFail:(NSError*)error{ | |
NSLog(@"%@", error); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// longitude and latitude are optional | |
[socialize createCommentForEntityWithKey:@"www.yourentityurl.com" comment:@"comment over here" longitude:nil latitude:nil]; | |
#pragma mark SocializeServiceDelegate implementation | |
// if the operation fails the following method is called | |
-(void)service:(SocializeService*)service didFail:(NSError*)error{ | |
NSLog(@"%@", error); | |
} | |
//if the comment was created successfully | |
-(void)service:(SocializeService*)service didCreate:(id<SocializeObject>)object{ | |
if ([object conformsToProtocol:@protocol(SocializeComment)]){ | |
id<SocializeComment> comment = (id<SocializeComment>)object; | |
// a comment represented by id<SocializeComment> has been created, so have at it | |
// do your magic here | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[socialize createEntityWithUrl:entityKey andName:name] | |
#pragma mark SocializeServiceDelegate | |
// if the operation fails the following method is called | |
-(void)service:(SocializeService*)service didFail:(NSError*)error{ | |
NSLog(@"%@", error); | |
} | |
//if the delete is successful | |
-(void)service:(SocializeService*)service didCreate:(id<SocializeObject>)object{ | |
NSLog(@"entity created"); | |
} | |
#pragma mark - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// invoke the call if you would like the SDK to receive a third party access token | |
[socialize authenticateWithApiKey:@"Authenticating" apiSecret:@"ApiSecret" thirdPartyAppId:@"AppId" thirdPartyName:FacebookAuth]; | |
// invoke the call if you already have the third party access token | |
[socialize authenticateWithApiKey:@"ApiKey" apiSecret:@"ApiSecret" thirdPartyAuthToken: @"ThirdPartyToken" thirdPartyAppId:@"AppId" thirdPartyName:FacebookAuth]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allocate memory for the instance | |
Socialize* socialize = [[Socialize alloc] initWithDelegate:self]; | |
/*Note | |
Each request is limited to 100 items. | |
If first = 0, last = 50, the API returns comments 0-49. | |
If last - first > 100, then last is truncated to equal first + 100. For example, if first = 100, last = 250, then last is changed to last = 200. | |
If only last = 150 is passed, then last is truncated to 100. If last = 25, then results 0...24 are returned. | |
*/ | |
[socialize getCommentList:@"urloftheentity" first:nil last:nil]; | |
/* | |
Implementing the delegate methods | |
getting/retrieving comments would invoke this callback and it would have elements of type id<SocializeComment> | |
*/ | |
-(void)service:(SocializeService*)service didFetchElements:(NSArray*)dataArray{ | |
// the array will contain elements of type id<SocializeComment> from where further info could be retrieved | |
} | |
//in case of error | |
-(void)service:(SocializeService*)service didFail:(NSError*)error{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allocate | |
Socialize* socialize = [[Socialize alloc] initWithDelegate:self]; | |
// We need the implement the delegate methods, none of which are required, they are all optional | |
#pragma mark SocializeServiceDelegate | |
// this method is optional | |
-(void)service:(SocializeService*)service didDelete:(id<SocializeObject>)object{ | |
} | |
// this method is optional | |
-(void)service:(SocializeService*)service didUpdate:(id<SocializeObject>)object{ | |
} | |
// this method is optional | |
-(void)service:(SocializeService*)service didFail:(NSError*)error{ | |
} | |
// this method is optional | |
-(void)service:(SocializeService*)service didCreate:(id<SocializeObject>)object{ | |
} | |
// this method is optional | |
-(void)service:(SocializeService*)service didFetchElements:(NSArray*)dataArray{ | |
} | |
// this method is optional | |
-(void)didAuthenticate{ | |
} | |
#pragma mark - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allocate memory for the instance | |
Socialize* socialize = [[Socialize alloc] initWithDelegate:self]; | |
// invoke the call (the latitude and the longitude can be nil) | |
[socialize viewEntity:entity longitude:nil latitude:nil]; | |
// creating a view would invoke this callback and it would have an element of type id<SocializeView> | |
-(void)service:(SocializeService*)service didCreate:(id<SocializeObject>)object{ | |
if ([object conformsToProtocol:@protocol(SocializeView)]){ | |
// do your magic/logic here | |
} | |
} | |
//in case of error | |
-(void)service:(SocializeService*)service didFail:(NSError*)error{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allocate memory for the instance | |
Socialize* socialize = [[Socialize alloc] initWithDelegate:self]; | |
// invoke the call (the latitude and the longitude can be nil) | |
[socialize likeEntityWithKey:@"www.url.com" longitude:[NSNumber numberWithFloat:-37.256] latitude:[NSNumber numberWithFloat:122.452314] | |
]; | |
#pragma mark SocializeServiceDelegate | |
//if the like fails this is called | |
-(void)service:(SocializeService*)service didFail:(NSError*)error{ | |
} | |
// if the like is created this is called | |
-(void)service:(SocializeService*)service didCreate:(<id>SocializeObject)object{ | |
//_like is object level instance of type <SocializeLike> | |
if ( [object conformsToProtocol:@protocol(SocializeLike)]){ | |
//_like = (id<SocializeLike>)object; | |
// do your magic here | |
} | |
} | |
#pragma mark - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allocate memory for the instance | |
Socialize* socialize = [[Socialize alloc] initWithDelegate:self]; | |
//like is the id<SocializeLike> object which was returned as a result of liking the entity. | |
[socialize unlikeEntity:like]; | |
// if the operation fails the following method is called | |
-(void)service:(SocializeService*)service didFail:(NSError*)error{ | |
NSLog(@"%@", error); | |
} | |
//if the delete is successful | |
-(void)service:(SocializeService*)service didDelete:(id<SocializeObject>)object{ | |
NSLog(@"entity unlike succeeded"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment