samedi 9 mai 2015

how to create invoice using ApI in ios

I tried to create invoice of paypal using the follwing url invoiceurl

I wrote the following code

 NSURL *url = [NSURL  URLWithString:@"http://ift.tt/1rqEcHT"];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
NSData *requestData = [NSData dataWithBytes:[jsonString UTF8String] length:[jsonString length]];

[request setHTTPMethod:@"POST"];
[request setValue:@"sender_ssa_api1.gmail.com" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];
[request setValue:@"AYL24E5YABQJ7S3Q" forHTTPHeaderField:@"PAYPAL-SECURITY-PASSWORD"];
[request setValue:@"A9kCtldabx3cNH-JvrasyD5dOesXAF61m6tDSZ.A7OCniSLwPFV0-A5e" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];
[request setValue:@"APP-80W284485P519543T" forHTTPHeaderField:@"X-PAYPAL-APPLICATION-ID"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];

[NSURLConnection connectionWithRequest:request delegate:self];
}

- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
 NSMutableData *d = [NSMutableData data];
 [d appendData:data];

NSString *a = [[NSString alloc] initWithData:d encoding:NSASCIIStringEncoding];

NSLog(@"Data: %@", a);
}

I got authentication error. Please help me how to do it in ios.

thanks inadvance

Aucun commentaire:

Enregistrer un commentaire