- Joined
- Apr 17, 2018
- Messages
- 22,498
I've been using a script to optimize my PropellerAds campaigns for a few years now. I originally created it to optimize a PeerFly campaign if that tells you anything
Before I begin, let me be clear: I am not a programmer. If you are a programmer, you will probably find my code sloppy and not optimal. I've hacked together this code and used it on and off for years. It works which is all I care about
Also, this code will not do you any good if you do not have a PropellerAds API key, which you can find here.
First, I use a PHP function to make the API calls that looks like this:
Before I begin, let me be clear: I am not a programmer. If you are a programmer, you will probably find my code sloppy and not optimal. I've hacked together this code and used it on and off for years. It works which is all I care about
Also, this code will not do you any good if you do not have a PropellerAds API key, which you can find here.
First, I use a PHP function to make the API calls that looks like this:
PHP:
// API calls
function API($method, $url, $data, $token = "") {
// https://www.weichieprojects.com/blog/curl-api-calls-with-php/
$curl = curl_init();
switch ($method){
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PATCH":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// OPTIONS:
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer $token",
'Content-Type: application/json',
));