我想使用libsoup执行一个简单的POST请求。我想发送数据的网站的api只需要一个名为'content'的字段。卷曲我这样做:
curl -si -F 'content=mycontent' http://mywebsite.org/api
我如何使用libsoup做同样的事情?
答案 0 :(得分:2)
从那里你应该尝试类似于
的东西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