卷曲到PHP向服务器提交请求 [英] Curl to PHP submitting request to server

查看:59
本文介绍了卷曲到PHP向服务器提交请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我有这一系列的代码,我可以从voluum服务器获取数据,但问题是我不能改变任何东西使用PUT我不知道我是否有正确的语法服务器请求改变



令牌;

$ id ='asdafewfcs';

$ karon = date(Ymd);

$ datetime = new DateTime('明天');





$ sh = curl_init();

curl_setopt($ sh,CURLOPT_URL,https://portal.voluum.com/report?from=。$ karon。T00:00:00Z& to =。$ datetime-> format('Ym-d ')。T00:00:00Z& tz = Etc%2FGMT& sort = revenue& direction = desc& columns = offerName& columns = visits& columns = clicks& columns = conversions& columns = revenue& columns = cost& columns =利润&安培;柱= CPV&安培;柱= CTR&安培;柱= CR安培;柱= CV&安培;柱= ROI&安培;柱= EPV&安培;柱= EPC&安培;柱= AP&安培;柱= affiliateNetworkName&安培; GROUPBY =报价&安培;偏移= 0&安培;限= 100安培;包括=活性&安培; 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'

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']为$ 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请求:。
;

$ campinfo = json_decode($ resulta,true);

echo'

';
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'

';
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)); //我觉得问题在这里

curl_setopt($ xh,CURLOPT_CUSTOMREQUEST,PUT);

$ headerss = array();

$ headerss [] =Cwauth-Token:。 $ TOK;

curl_setopt($ xh,CURLOPT_HTTPHEADER,$ headers);



$ 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);

?>



这里是我要更改的短数据

数组



[路径组] =>数组



[ 0] =>数组







[路径] =>数组



[0] =>数组



[重量] => 100

[有效] => 1

[landers] =>数组



[0] =>数组



[登陆] =>数组



[id] =>

[namePostfix] =>

[name] =>





[体重] => 100









[offer] =>数组



[0] =>数组



[offer] =>数组< br $> b $ b(

[id] =>

[name] =>

[namePostfix] =>





[重量] => 100



< br $> b $ b)











[有效] => 1 //这就是我想要取代的东西我希望它变成假的

















我尝试了什么:



以上代码是我到目前为止所尝试的

';
$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

推荐答案

id ='asdafewfcs';
id = 'asdafewfcs';


karon = date(Ymd);
karon = date("Y-m-d");


datetime = new DateTime( '明天');




datetime = new DateTime('tomorrow');



这篇关于卷曲到PHP向服务器提交请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆