Skip to content

Instantly share code, notes, and snippets.

@malwador
Created October 19, 2016 00:48
Show Gist options
  • Save malwador/2f070c485f8172364bf4efd7a30f2b2c to your computer and use it in GitHub Desktop.
Save malwador/2f070c485f8172364bf4efd7a30f2b2c to your computer and use it in GitHub Desktop.
Simple Script in PHP to clear sucuri's cloudproxy cache via php
<?php
/**
* Simple Script in PHP to clear sucuri's cloudproxy cache via php
*
* Author: Salvador Aguilar
* Email: sal.aguilar81@gmail.com
* Web: salrocks.com
*/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://waf.sucuri.net/api?v2',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
// this is the Sucuri CloudProxy API key for this website
k => 'your-cloudproxy-api-key-goes-here',
// this is the Sucuri CloudProxy API secret for this website
s => 'your-cloudproxy-api-secret-goes-here',
// this is the Sucuri CloudProxy API action for this website
a => 'clear_cache'
)
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
echo '<pre>' . $resp . '</re>';
// Close request to clear up some resources
curl_close($curl);
@ItsJustATypo
Copy link

Very helpful, thank you. To use this with Godaddy's version of Sucuri, I had to set the CURLOPT_POSTFIELDS array keys as strings, e.g.:

    CURLOPT_POSTFIELDS => array(
        'k' => 'your-godaddy-api-key-goes-here',
        's' => 'your-godaddy-api-secret-goes-here',
        'a' => 'clear_cache'
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment