HTTP POST with libsoup

后端 未结 1 1966
故里飘歌
故里飘歌 2021-01-16 11:08

I\'d like to execute a simple POST request using libsoup. The api of the website i\'d like to send data to requires only one field named \'content\'. With curl i do this:

相关标签:
1条回答
  • 2021-01-16 11:51

    Google probably does this better for you than me. Here is a link with the libsoup client basics. http://developer.gnome.org/libsoup/stable/libsoup-client-howto.html

    From there you should try something similar to

    guint status;
    SoupMessage *msg;
    const char * mycontent; //alloc and fill this with your data
    msg = soup_message_new ("POST", "http://example.com/form.cgi");
    soup_message_set_request (msg, "whatever content type here",
              SOUP_MEMORY_COPY, mycontent, strlen (mycontent));
    status = soup_session_send_message (session, msg);
    //error handling etc
    
    0 讨论(0)
提交回复
热议问题