Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have this series of code i can grab data from voluum server but the problem is i cant alter anything when using PUT i dont know if i have the right syntax for server request to alter

token;
$id = 'asdafewfcs';
$karon = date("Y-m-d");
$datetime = new DateTime('tomorrow');


$sh = curl_init();
curl_setopt($sh, CURLOPT_URL, "https://portal.voluum.com/report?from=" .$karon. "T00:00:00Z&to=" . $datetime->format('Y-m-d') . "T00:00:00Z&tz=Etc%2FGMT&sort=revenue&direction=desc&columns=offerName&columns=visits&columns=clicks&columns=conversions&columns=revenue&columns=cost&columns=profit&columns=cpv&columns=ctr&columns=cr&columns=cv&columns=roi&columns=epv&columns=epc&columns=ap&columns=affiliateNetworkName&groupBy=offer&offset=0&limit=100&include=active&filter1=campaign&filter1Value=" . $id);
curl_setopt($sh, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($sh, CURLOPT_CUSTOMREQUEST, "GET");


$header = array();
$header[] = "Cwauth-Token: " . $tok;
curl_setopt($sh, CURLOPT_HTTPHEADER, $header);

$results = curl_exec($sh);
if (curl_errno($sh)) {
echo 'Error:' . curl_error($sh);
}

$user = json_decode($results, true);
echo '
' . print_r($user, TRUE) . '
';
foreach($user['rows'] as $mydata)
{
$visit = $mydata['visits'] ;
echo $visit . "\n
";
if($visit >= 10){

$wh = curl_init();

curl_setopt($wh, CURLOPT_URL, "https://core.voluum.com/campaigns/" . $id);
curl_setopt($wh, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($wh, CURLOPT_CUSTOMREQUEST, "GET");


$head = array();
$head[] = "Cwauth-Token: " . $tok;
curl_setopt($wh, CURLOPT_HTTPHEADER, $head);

$resulta = curl_exec($wh);
if (curl_errno($wh)) {
echo 'Error:' . curl_error($wh);
}
echo "Request:" . "
";
$campinfo = json_decode($resulta, true);
echo '
' . print_r($campinfo, TRUE) . '
';
foreach($campinfo['pathsGroups'] as $datacamp){
$datacamp['active'] = 0;
echo '
' . print_r($datacamp, true). '
';
$xh = curl_init();

curl_setopt($xh, CURLOPT_URL, "https://core.voluum.com/campaigns/" . $id);
curl_setopt($xh, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($xh, CURLOPT_POSTFIELDS,http_build_query($datacamp)); // i think problem is here
curl_setopt($xh, CURLOPT_CUSTOMREQUEST, "PUT");
$headerss = array();
$headerss[] = "Cwauth-Token: " . $tok;
curl_setopt($xh, CURLOPT_HTTPHEADER, $headerss);

$result = curl_exec($xh);
if (curl_errno($xh)) {
echo 'Error:' . curl_error($xh);
}


}


}

}



curl_close ($ch);
curl_close ($sh);
curl_close ($wh);
curl_close ($xh);
?>

here is a short data that i want to change
Array
(
[pathsGroups] => Array
(
[0] => Array
(


[paths] => Array
(
[0] => Array
(
[weight] => 100
[active] => 1
[landers] => Array
(
[0] => Array
(
[lander] => Array
(
[id] =>
[namePostfix] =>
[name] =>
)

[weight] => 100
)

)

[offers] => Array
(
[0] => Array
(
[offer] => Array
(
[id] =>
[name] =>
[namePostfix] =>
)

[weight] => 100
)

)

)

)

[active] => 1 //this is what i'am trying to replace i want it to become false
)

)



)

What I have tried:

well the code above is what i've tried so far
Posted
Updated 29-Nov-16 2:02am
Comments
Suvendu Shekhar Giri 29-Nov-16 8:38am    
"voluum server"
what is that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900