I had a problems while parsing (Using POST method) the data From server
here is my code , please help
void
get_http_data(const char* url, memoryStruct *data)
{
CURL *curl_handle;
CURLcode res;
data->memory = malloc(1); /* will be grown as needed by the realloc above */
data->size = 0; /* no data at this point */
curl_global_init(CURL_GLOBAL_ALL);
/* init the curl session */
curl_handle = curl_easy_init();
/* specify URL to get */
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
/* send all data to this function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_memory_cb);
/////
struct curl_slist *list = NULL;
list = curl_slist_append(list, "Content-Type: application/json");
curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, list);
//curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER,"Content-Type: application/json");
curl_easy_setopt (curl_handle, CURLOPT_HTTPPOST, 1L);
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, "sign=aries&day=today");
/////
/* we pass our 'chunk' struct to the callback function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)data);
/* some servers don't like requests that are made without a user-agent
field, so we provide one */
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
/* get it! */
res = curl_easy_perform(curl_handle);
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
/* we're done with libcurl, so clean it up */
curl_global_cleanup();
}
void Get_Horoscope_Response(void *data, char *Sign, char *Day)
{
appdata_s *ad=data;
//dlog_print(DLOG_ERROR, LOG_TAG, "Dinal *** 1");
JsonParser *parser = json_parser_new ();
char url[PATH_MAX];
sprintf(url, "https://aztro.herokuapp.com");
get_http_data(url,&ad->ms);
elm_object_text_set(ad->label,ad->ms.memory);
if(json_parser_load_from_data( parser,ad->ms.memory, strlen(ad->ms.memory), NULL))
{
JsonNode *root = json_parser_get_root(parser);
JsonObject *obj = json_node_get_object(root);
const char *compatibility = json_object_get_string_member(obj,"compatibility");
dlog_print(DLOG_INFO, LOG_TAG, "Dinal compatibility : %s",compatibility);
}
}
it sets ” ‘null’ Try Again? Seems to be some kind of problem in the parameters 🙂 ” to my Entry ad->label
my Response seems to be in this format :
{"current_date":"June 23, 2017","compatibility":" Cancer","lucky_time":" 7am","lucky_number":" 64","color":" Spring Green","date_range":"Mar 21 - Apr 20","mood":" Relaxed","description":"It's finally time for you to think about just one thing: what makes you happy. Fortunately, that happens to be a person who feels the same way. Give yourself the evening off. Refuse to be put in charge of anything."}
HTTP Post Method in Tizen
Hello Everyone,
I had a problems while parsing (Using POST method) the data From server
here is my code , please help
it sets ” ‘null’ Try Again? Seems to be some kind of problem in the parameters 🙂 ” to my Entry ad->label
my Response seems to be in this format :
My Log :
Dinal compatibility : (null)
refrence link : https://aztro.readthedocs.io/en/latest/
Thank You, Dinal Jivani 😀
BY
16 Apr 2025
Tizen Studio
BY
04 Nov 2024
Tizen Studio
BY
02 Apr 2024
Tizen Studio