from DeathByNukes.
.
3 - You create a command-line with curl.exe that works, and add "--libcurl <file>" as option to let it output the code to a file.
4 - You open the created file and have a look at the necessary calls to CurlEasySetOption.
/********* Sample code generated by the curl command line tool **********
* Lines with [REMARK] below might need to be modified to make this code
* usable. Add error code checking where appropriate.
* Compile this with a suitable header include path. Then link with
* libcurl.
* If you use any *_LARGE options, make sure your compiler figure
* out the correct size for the curl_off_t variable.
* Read the details for all curl_easy_setopt() options online on:
*
http://curlm.haxx.se/libcurl/c/curl_easy_setopt.html ************************************************************************/
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd = curl_easy_init();
/* curl_easy_setopt(hnd, CURLOPT_WRITEDATA, 0x22fee8); [REMARK] */
/* curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, 0x4056a4); [REMARK] */
/* curl_easy_setopt(hnd, CURLOPT_READDATA, 0x22ff2c); [REMARK] */
/* curl_easy_setopt(hnd, CURLOPT_READFUNCTION, 0x40563c); [REMARK] */
/* curl_easy_setopt(hnd, CURLOPT_SEEKDATA, 0x22ff2c); [REMARK] */
/* curl_easy_setopt(hnd, CURLOPT_SEEKFUNCTION, 0x404fe0); [REMARK] */
curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)-1);
curl_easy_setopt(hnd, CURLOPT_URL, "http://www.uitzendinggemist.nl/");
curl_easy_setopt(hnd, CURLOPT_PROXY, NULL);
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(hnd, CURLOPT_HEADER, 0);
curl_easy_setopt(hnd, CURLOPT_FAILONERROR, 0);
curl_easy_setopt(hnd, CURLOPT_UPLOAD, 0);
curl_easy_setopt(hnd, CURLOPT_DIRLISTONLY, 0);
curl_easy_setopt(hnd, CURLOPT_APPEND, 0);
curl_easy_setopt(hnd, CURLOPT_NETRC, 0);
curl_easy_setopt(hnd, CURLOPT_FOLLOWLOCATION, 0);
curl_easy_setopt(hnd, CURLOPT_UNRESTRICTED_AUTH, 0);
curl_easy_setopt(hnd, CURLOPT_TRANSFERTEXT, 0);
curl_easy_setopt(hnd, CURLOPT_USERPWD, NULL);
curl_easy_setopt(hnd, CURLOPT_PROXYUSERPWD, NULL);
curl_easy_setopt(hnd, CURLOPT_NOPROXY, NULL);
curl_easy_setopt(hnd, CURLOPT_RANGE, NULL);
/* curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, 0x22fd98); [REMARK] */
curl_easy_setopt(hnd, CURLOPT_TIMEOUT, 0);
curl_easy_setopt(hnd, CURLOPT_REFERER, NULL);
curl_easy_setopt(hnd, CURLOPT_AUTOREFERER, 0);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0;)");
curl_easy_setopt(hnd, CURLOPT_FTPPORT, NULL);
curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_LIMIT, 0);
curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_TIME, 0);
curl_easy_setopt(hnd, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t)0);
curl_easy_setopt(hnd, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t)0);
curl_easy_setopt(hnd, CURLOPT_RESUME_FROM_LARGE, (curl_off_t)0);
curl_easy_setopt(hnd, CURLOPT_COOKIE, NULL);
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(hnd, CURLOPT_SSLCERT, NULL);
curl_easy_setopt(hnd, CURLOPT_SSLCERTTYPE, NULL);
curl_easy_setopt(hnd, CURLOPT_SSLKEY, NULL);
curl_easy_setopt(hnd, CURLOPT_SSLKEYTYPE, NULL);
curl_easy_setopt(hnd, CURLOPT_KEYPASSWD, NULL);
curl_easy_setopt(hnd, CURLOPT_SSH_PRIVATE_KEYFILE, NULL);
curl_easy_setopt(hnd, CURLOPT_SSH_PUBLIC_KEYFILE, NULL);
curl_easy_setopt(hnd, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, NULL);
curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 2);
curl_easy_setopt(hnd, CURLOPT_SSH_KNOWNHOSTS, "C:\Documents and Settings\User\Application Data/_ssh/known_hosts");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50);
curl_easy_setopt(hnd, CURLOPT_CRLF, 0);
curl_easy_setopt(hnd, CURLOPT_QUOTE, NULL);
curl_easy_setopt(hnd, CURLOPT_POSTQUOTE, NULL);
curl_easy_setopt(hnd, CURLOPT_PREQUOTE, NULL);
curl_easy_setopt(hnd, CURLOPT_WRITEHEADER, NULL);
curl_easy_setopt(hnd, CURLOPT_COOKIEFILE, NULL);
curl_easy_setopt(hnd, CURLOPT_COOKIEJAR, "F:\Downloads\100302\curl_DLL_ONLY\nossl\testcooo.txt");
curl_easy_setopt(hnd, CURLOPT_COOKIESESSION, 0);
curl_easy_setopt(hnd, CURLOPT_SSLVERSION, 0);
curl_easy_setopt(hnd, CURLOPT_TIMECONDITION, 0);
curl_easy_setopt(hnd, CURLOPT_TIMEVALUE, 0);
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, NULL);
/* curl_easy_setopt(hnd, CURLOPT_STDERR, 0x77c5fcc0); [REMARK] */
curl_easy_setopt(hnd, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_easy_setopt(hnd, CURLOPT_INTERFACE, NULL);
curl_easy_setopt(hnd, CURLOPT_KRBLEVEL, NULL);
curl_easy_setopt(hnd, CURLOPT_TELNETOPTIONS, NULL);
curl_easy_setopt(hnd, CURLOPT_RANDOM_FILE, NULL);
curl_easy_setopt(hnd, CURLOPT_EGDSOCKET, NULL);
curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT, 0);
curl_easy_setopt(hnd, CURLOPT_ENCODING, NULL);
curl_easy_setopt(hnd, CURLOPT_FTP_CREATE_MISSING_DIRS, 0);
curl_easy_setopt(hnd, CURLOPT_IPRESOLVE, 0);
curl_easy_setopt(hnd, CURLOPT_FTP_ACCOUNT, NULL);
curl_easy_setopt(hnd, CURLOPT_IGNORE_CONTENT_LENGTH, 0);
curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 0);
curl_easy_setopt(hnd, CURLOPT_FTP_FILEMETHOD, 0);
curl_easy_setopt(hnd, CURLOPT_FTP_ALTERNATIVE_TO_USER, NULL);
curl_easy_setopt(hnd, CURLOPT_SSL_SESSIONID_CACHE, 1);
/* curl_easy_setopt(hnd, CURLOPT_SOCKOPTFUNCTION, 0x405018); [REMARK] */
/* curl_easy_setopt(hnd, CURLOPT_SOCKOPTDATA, 0x22f8b8); [REMARK] */
curl_easy_setopt(hnd, CURLOPT_POSTREDIR, 0);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
return (int)ret;
}
/**** End of sample code ****/
is the Dutch public broadcasting site. To be able to view video, one has to go to the site. This annoyed me, because I wanted to be able to get the video stream address from any particular video, so I could play it back in VLC, without having to consult my firewall or some other sniffing app.
So, here comes curl/libcurl to the resque.
to be able to monitor the traffic.
) and waited until the video started playing, stopped the monitoring and analyzed the calls made.
The third link retreives a .js file with the following in the first line: "var securityCode = '624bba93a664a6fe173eacdcb13f9d6b';var useFactor = true;"
This securityCode is what I need to be able to call the fourth link.
To use curl/libcurl to submit forms, check the documentation (-d/--data <data> and/or --data-urlencode <data> and/or -F/--form <name=content> and/or --form-string <name=string>)