• Welcome to affLIFT!
    We are happy you have decided to check out our awesome affiliate marketing forum. Register your account today to join our amazing community!
  • 30% off for ad tracking & automation! Leading affiliates & media buyers use RedTrack for 5-minute cost updates, campaign management, smart rules, CAPI integrations with FB, TikTok, Google Ads, Bing, etc.
    Get 30% OFF!

Guide Create a PHP Script to Optimize PropellerAds

AdsEmpire

Luke

Admin
Staff Member
Community Leader
Joined
Apr 17, 2018
Messages
20,840
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 :D

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',
    ));
 
To view the premium content in our affiliate marketing forum (including this awesome thread), you must first register and upgrade your account. Register today and become a part of our amazing community!
Top