언어 설정

Menu
Sites
Language
code for http request in native 2.3

In  my application,I need to connect to webpage in native 2.3

i search code in websites, but i not found exactly 

so anyone snd the exact code to call webpage in my app

Responses

6 댓글
Alex Ashirov

Hi,

You need to use Curl lib in order to send http requests:

http://curl.haxx.se/libcurl/c/

Please see the following link for samples:

http://curl.haxx.se/libcurl/c/example.html

Anusha Sajeendran
int clicked_cb(void) {
   CURL *curl;
   CURLcode res;

   curl = curl_easy_init();
   if(curl) {
     curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com");
      //example.com is redirected, so we tell libcurl to follow redirection
     curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    //  Perform the request, res will get the return code
     res = curl_easy_perform(curl);
     // Check for errors
     if(res != CURLE_OK){
    dlog_print(DLOG_ERROR, LOG_TAG, "CurlFail", res);
      elm_exit();
     }
     // always cleanup
     curl_easy_cleanup(curl);
   }
   return 0;
 }

Hi,

This is the code I have used for calling a page using lib curl functions in the native app 2.3.0. I have a button which calls "clicked_cb". But I dont find the app redirecting to Google or the specified URL. Can anyone help me.

Alex Ashirov

Hi,

What is a value returned by curl_easy_perform()? If it returns CURLE_OK then everything is ok and your code works as expected.

Anusha Sajeendran

Hi,

It is returning 0. And thus it is going into the if condition.
 

Alex Ashirov

Hi,

Strange, because CURLE_OK is zero:

http://curl.haxx.se/libcurl/c/libcurl-errors.html

Donovan

You need to add a privilege to your application. I'd show you how but this crappy forum doesnt even let you upload images. But in Eclipse IDE open the tizen-manifiest.xml and go to the Privilege tab, and add the tizen.org/privilege/internet privilge