Created
September 8, 2014 09:27
-
-
Save eytanschulman/832d97c286c3e9fb2590 to your computer and use it in GitHub Desktop.
WBAIS App API Request
This file contains hidden or 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
-(void)executeCalendarRequest { | |
NSString *clientID = [[[GPPSignIn sharedInstance] authentication] clientID]; | |
NSString *clientSecret = @"z4TA1SX2O9Fmf0Xr76-HASBy"; | |
NSString *accessToken = [[[GPPSignIn sharedInstance] authentication] accessToken]; | |
NSLog(@"clientID = %@",clientID); | |
NSLog(@"clientSecret = %@",clientSecret); | |
NSLog(@"accessToken = %@",accessToken); | |
[nameLabel setText:[NSString stringWithFormat:@"%@ %@",globalPerson.name.givenName,globalPerson.name.familyName]]; | |
// [self.googleOAuth authorizeUserWithClienID:clientID | |
// andClientSecret:clientSecret | |
// andParentView:self.view | |
// andScopes:[NSArray arrayWithObject:@"https://www.googleapis.com/auth/calendar"]]; | |
// NSString *requestURL = [NSString stringWithFormat:@"https://www.googleapis.com/calendar/v3/users/me/calendarList/access_token=1/%@",[[[GPPSignIn sharedInstance] authentication] accessToken]]; | |
NSString *requestURL = [NSString stringWithFormat:@"https://www.googleapis.com/calendar/v3/users/me/calendarList/&key=%@",[[GPPSignIn sharedInstance] authentication].accessToken]; | |
// NSString *requestURL = [NSString stringWithFormat:@"https://www.googleapis.com/auth/calendar?%@",[[GPPSignIn sharedInstance] authentication].accessToken]; | |
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:requestURL] | |
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData | |
timeoutInterval:10]; | |
[request setHTTPMethod: @"GET"]; | |
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; | |
[self makeRequest:request]; | |
} | |
//This method gets ran when the data comes in from the server, and logs the response | |
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ | |
// Append any new data to the _receivedData object. | |
[_receivedData appendData:data]; | |
NSLog(@"receivedData = %@",_receivedData); | |
NSLog(@"data = %@",data); | |
NSError* error; | |
NSDictionary* json = [NSJSONSerialization | |
JSONObjectWithData:data | |
options:kNilOptions | |
error:&error]; | |
NSLog(@"json = %@",json); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment