Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl = curl_easy_init();
- //GET
- curl_easy_setopt(curl, CURLOPT_URL, POST?arg[0]:make);
- //caso seja post inves de GET
- if(POST)
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, make);
- // response fica em um pedaço da memoria
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
- // caso usuario tenha definido um useragent
- if(arg[6]!=NULL)
- curl_easy_setopt(curl, CURLOPT_USERAGENT, arg[6]);
- // do contrario vamos usar o useragent padrao
- else
- curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (0d1n v0.1) ");
- // para comprimir
- curl_easy_setopt(curl, CURLOPT_ENCODING,"gzip,deflate");
- //uso futuro do timeout
- // curl_easy_setopt(curl, CURLOPT_SETIMEOUT,3);
- //caso seja definido um cookiejar
- if(arg[3]!=NULL)
- {
- curl_easy_setopt(curl,CURLOPT_COOKIEFILE,arg[3]);
- curl_easy_setopt(curl,CURLOPT_COOKIEJAR,arg[3]);
- } else
- // do contrario cria uma arquivo em branco para armazenar os cookies
- curl_easy_setopt(curl,CURLOPT_COOKIEJAR,"odin_cookiejar.txt");
- // caso tenha redirecionamento
- curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1);
- // nao verifica cert SSL
- curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,0);
- // mostra header no response
- curl_easy_setopt(curl,CURLOPT_HEADER,1);
- curl_easy_perform(curl);
- // para pegar status,200,403...
- curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE,&status);
- curl_easy_cleanup(curl);
Advertisement
Add Comment
Please, Sign In to add comment