WhatsApp Integration with Objective-C – NSURLSession

Jun 5, 2021 | API Documentation | 0 comments

GET

Login to Waapi

http://192.168.1.36:44442/api/login?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in&serverKey=FYE-DKX-PSX-UNV-BAN

login your instance

  PARAMS
  from
  GKH-UIJ-UGE-FGH-MLV
  email
  admin@callcenter.in
  serverKey   FYE-DKX-PSX-UNV-BAN
Example Request                       Login to Waapi
#import <Foundation/Foundation.h> dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@”http://192.168.1.36:44442/api/login?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in&serverKey=FYE-DKX-PSX-UNV-BAN”] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@”GET”]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@”%@”, error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; NSLog(@”%@”,responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

GET

Send Text Message

http://192.168.1.36:44442/api/sendmessage?from=GKH-UIJ-UGE-FGH-MLV&message=your message&type=text&to=012138227697&messageId=ab1asas3t2ss4aas1g5&callback=http://your-url.com/get/waapi/status
  PARAMS
  from
  GKH-UIJ-UGE-FGH-MLV
  message
  your message
  type   text
  to
  012138227697
  messageId   ab1asas3t2ss4aas1g5
  callback
  http://your-url.com/get/waapi/status
Example Request                          Send Text Message

#import <Foundation/Foundation.h> dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@”http://192.168.1.36:44442/api/sendmessage?from=GKH-UIJ-UGE-FGH-MLV&message=your%20message&type=text&to=012138227697&messageId=ab1asas3t2ss4aas1g5&callback=http://your-url.com/get/waapi/status”] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@”GET”]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@”%@”, error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; NSLog(@”%@”,responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

GET

Send Image/Video Message

http://192.168.1.36:44442/api/sendMessage?from=GKH-UIJ-UGE-FGH-MLV&caption=test caption&message=https://www.waapi.in/wp-content/uploads/2021/04/WA.png&type=document&to=012138227697&messageId=ab1asas3t2ss4aas1g5&callback=http://your-url.com/get/waapi/status
  PARAMS
  from
  GKH-UIJ-UGE-FGH-MLV
  caption
  test caption
  message
  https://www.waapi.in/wp-content/uploads/2021/04/WA.png
  type   document
  to   012138227697
  messageId
  ab1asas3t2ss4aas1g5
  callback   http://your-url.com/get/waapi/status
Example Request                 Send Image/Video Message
#import <Foundation/Foundation.h> dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@”http://192.168.1.36:44442/api/sendMessage?from=GKH-UIJ-UGE-FGH-MLV&caption=test%20caption&message=https://www.waapi.in/wp-content/uploads/2021/04/WA.png&type=document&to=012138227697&messageId=ab1asas3t2ss4aas1g5&callback=http://your-url.com/get/waapi/status”] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@”GET”]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@”%@”, error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; NSLog(@”%@”,responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

GET

Send Document(PDF,CSV)

http://192.168.1.36:44442/api/sendMessage?from=GKH-UIJ-UGE-FGH-MLV&message=https://www.waapi.in/wp-content/uploads/2021/04/WA.png&type=document&to=012138227697&messageId=ab1asas3t2ss4aas1g5&callback=http://your-url.com/get/waapi/status

Note :
caption could not be sent with file’s , it will be sent as text message while sending pdf
caption is optional parameter

  PARAMS
  from
GKH-UIJ-UGE-FGH-MLV
  caption
  test caption
  message
  https://www.waapi.in/wp-content/uploads/2021/04/WA.png
  type   document
  to   012138227697
  messageId
  ab1asas3t2ss4aas1g5
  callback   http://your-url.com/get/waapi/status
Example Request                             Send Document(PDF,CSV)
#import <Foundation/Foundation.h> dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@”http://192.168.1.36:44442/api/sendMessage?from=GKH-UIJ-UGE-FGH-MLV&message=https://www.waapi.in/wp-content/uploads/2021/04/WA.png&type=document&to=012138227697&messageId=ab1asas3t2ss4aas1g5&callback=http://your-url.com/get/waapi/status”] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@”GET”]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@”%@”, error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; NSLog(@”%@”,responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

GET

Message logs

http://192.168.1.36:44442/api/messagestatus?from=GKH-UIJ-UGE-FGH-MLV&fromdate=01-06-2021&todate=30-06-2021&fomat=json

format : html/json

Extra parameters :

status : Queued , NOT REGISTERED , SUCCESS , FAILED
number : search by customer number

  PARAMS
  from
  GKH-UIJ-UGE-FGH-MLV
  fromdate
  01-06-2021
  todate
  30-06-2021
  fomat   json

Example Request                         Message logs

#import <Foundation/Foundation.h> dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@”http://192.168.1.36:44442/api/messagestatus?from=GKH-UIJ-UGE-FGH-MLV&fromdate=01-06-2021&todate=30-06-2021&fomat=json”] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@”GET”]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@”%@”, error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; NSLog(@”%@”,responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

GET

Check Server Status

http://192.168.1.36:44442/api/serverstatus?from=GKH-UIJ-UGE-FGH-MLV&flag=login

check instance is logged in on server or not

  PARAMS
  from
  GKH-UIJ-UGE-FGH-MLV
  flag   login
Example Request                          Check Server Status

#import <Foundation/Foundation.h> dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@”http://192.168.1.36:44442/api/serverstatus?from=GKH-UIJ-UGE-FGH-MLV&flag=login”] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@”GET”]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@”%@”, error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; NSLog(@”%@”,responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

GET

Logout

http://192.168.1.36:44442/api/logout?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in

Logout for your instance , old data may deleted

  PARAMS
  from
  GKH-UIJ-UGE-FGH-MLV
  email   admin@callcenter.in
Example Request                                        Logout

#import <Foundation/Foundation.h> dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@”http://192.168.1.36:44442/api/logout?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in”] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@”GET”]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@”%@”, error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; NSLog(@”%@”,responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

GET

Restart Server

http://192.168.1.36:44442/api/restart?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in

Restart your instance

  PARAMS
  from
  GKH-UIJ-UGE-FGH-MLV
  email   admin@callcenter.in
Example Request                          Restart Server
#import <Foundation/Foundation.h> dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@”http://192.168.1.36:44442/api/restart?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in”] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@”GET”]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@”%@”, error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; NSLog(@”%@”,responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Other posts you might like

WhatsApp Integration with Swift – URLSession

GET Login to Waapi http://192.168.1.36:44442/api/login?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in&serverKey=FYE-DKX-PSX-UNV-BAN login your instance   PARAMS   from   GKH-UIJ-UGE-FGH-MLV   email   admin@callcenter.in   serverKey   FYE-DKX-PSX-UNV-BAN...

WhatsApp Integration with Shell – wget

GET Login to Waapi http://192.168.1.36:44442/api/login?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in&serverKey=FYE-DKX-PSX-UNV-BAN login your instance   PARAMS   from   GKH-UIJ-UGE-FGH-MLV   email   admin@callcenter.in   serverKey   FYE-DKX-PSX-UNV-BAN...

WhatsApp Integration with Shell – Httpie

GET Login to Waapi http://192.168.1.36:44442/api/login?from=GKH-UIJ-UGE-FGH-MLV&email=admin@callcenter.in&serverKey=FYE-DKX-PSX-UNV-BAN login your instance   PARAMS   from   GKH-UIJ-UGE-FGH-MLV   email   admin@callcenter.in   serverKey   FYE-DKX-PSX-UNV-BAN...