Reputation: 94
I need to run a program in c++ for a long period of time that is making url requests on my site every 12 seconds, which triggers a php script. I figured out how to do the running, but every time it's making the "request", the browser pops up. You can't do anything while this program is running. So my question is: can I make the request for the page somehow so the browser didn't pop up? (My os is windows). That is the c++ function that I'm using:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
ShellExecute(NULL, "open", "http://www.google.com/",NULL, NULL, SW_MINIMIZE);
return 0;
}
Upvotes: 0
Views: 900
Reputation: 2278
A 3rd party http client with a C++ API like curl should work nicely for what you need. You can find the documentation on their website. Here is some very basic example code to make a URL request. You could just put it in a loop with a timer.
#include <curl/curl.h>
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
Upvotes: 3