Thread: help with libcurl

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    19

    help with libcurl

    hello, im learning to use libcurl post method, and i need some help...

    Code:
    #include <stdio.h>
    #include <curl/curl.h>
      
    int main(void){
        CURL *curl;
        CURLcode res;
      
        curl = curl_easy_init();
        if(curl) {
           
            curl_easy_setopt(curl, CURLOPT_URL, "localhost/config.php");        
            curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "$POST[in_chkcacic] => test1");  
          
            res = curl_easy_perform(curl);
    
            curl_easy_cleanup(curl);
        }
        return 0;
    }
    Can i use the bold parameter like this? I want to test sending a post to myself and that config.php was made to receive the post and write a return XML file...

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    This might work (looks like you're mixing up your PHP and C):
    Code:
    #include <stdio.h>
    #include <curl/curl.h>
      
    int main(void){
        CURL *curl;
        CURLcode res;
      
        curl = curl_easy_init();
        if(curl) {
           
            curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/config.php");        
            curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "in_chkcacic=test1");
          
            res = curl_easy_perform(curl);
    
            curl_easy_cleanup(curl);
        }
        return 0;
    }

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    19
    thx... but where should my config.php be placed? home?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Installing libcurl library
    By samus250 in forum C Programming
    Replies: 4
    Last Post: 04-01-2008, 07:28 PM
  2. libcurl program no output
    By shady_Dev in forum Linux Programming
    Replies: 5
    Last Post: 01-04-2008, 04:25 AM
  3. libcURL POST items
    By Pete in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-30-2007, 09:24 AM
  4. File Upload with libcurl
    By Tonto in forum Networking/Device Communication
    Replies: 4
    Last Post: 03-15-2006, 06:11 PM
  5. Problem with my libcurl attempt
    By kzar in forum C Programming
    Replies: 2
    Last Post: 05-21-2005, 01:28 PM