Hi I want to make RESTful call to remote sever. url is http://bulksms.net/API.svc/sms/json/sendmessage?username=newuser&password=newpasswd&msg=test&msisdn=9999999999&tagname=Demo&shortcode=8888&telcoId=5&dnRequired=false The server document says:
Parameters
string username, string password, string msg, string msisdn, string tagname, string shortcode, int telcoId, bool dnRequired
Return Value API will return and object containing three members IsSuccess Message UniqueId
I have made a sample client in c but its not working. below is my code.
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURL *curl;
char url[80];
CURLcode res;
strcpy(url,"http://bulksms.net/API.svc/sms/json/sendmessage?username=newuser&password=newpasswd&msg=test&msisdn=9999999999&tagname=Demo&shortcode=8888&telcoId=5&");
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POST, url);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}
Output :
I resolved the problem. Actually in RESTful POST method url and data should be added part by part. below is the successfull client in c for RESTfull POST method.
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURL *curl;
CURLcode res;
char url[]= "http://bulksms.net/API.svc/sms/json/sendmessage";
char postData[] = "username=newuser&password=newpasswd&msg=test&msisdn=9999999999&tagname=Demo&shortcode=8888&telcoId=5&dnRequired=false";
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With