2016-11-28 3 views
0

hallo php mir jemand was falsch mit meinem Code von true in false sagen kann, hiercurl customrequest

foreach($campinfo['pathsGroups'] as $datacamp){ 
        echo $datacamp['active']; 
        $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, "$datacamp['active']= "); 
        curl_setopt($xh, CURLOPT_CUSTOMREQUEST, "PUT"); 

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

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

iam versuchen Wert aktiv ändern die Daten zu ändern:

Array 
(
    [pathsGroups] => Array 
     (
      [0] => Array 
       (
        [condition] => Array 
         (
          [country] => Array 
           (
            [predicate] => MUST_BE 
            [countryCodes] => Array 
             (
              [0] => IQ 
             ) 

           ) 

          [customVariableConditions] => Array 
           (
            [0] => Array 
             (
              [predicate] => MUST_NOT_BE 
              [index] => 0 
              [texts] => Array 
               (
                [0] => 
                [1] => Unknown 
                [2] => unknown 
               ) 

              [text] => 
             ) 

            [1] => Array 
             (
              [predicate] => MUST_NOT_BE 
              [index] => 1 
              [texts] => Array 
               (
                [0] => Unknown 
                [1] => 
                [2] => unknown 
               ) 

              [text] => Unknown 
             ) 

            [2] => 
            [3] => 
            [4] => 
            [5] => 
            [6] => 
            [7] => 
            [8] => 
            [9] => 
           ) 

         ) 

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

                [weight] => 100 
               ) 

             ) 

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

                [weight] => 100 
               ) 

             ) 

           ) 

         ) 

        [active] => 1 //this is what iam trying to change to false or null or 0 
       ) 

     ) 



) 

Ich möchte das aktive zu false machen, um es auszuschalten, ist das möglich? Ich weiß nicht, ob dies der richtige Weg ist, um etwas zu ändern. kann jemand mir helfen, ich bin wirklich in diesem Teil stecken.

+0

'curl_setopt ($ xh, CURLOPT_POSTFIELDS, array ($ datacamp [ 'aktiv'] => 0)); ' –

+0

hallo danke für die Antwort Ich habe versucht, mit dem Code, den Sie zur Verfügung gestellt, und es sagt Seite funktioniert nicht. – ban

Antwort

0

vielleicht hilfreich

<?php  
$xh = curl_init(); 
curl_setopt($xh, CURLOPT_URL,"your URL"); 
curl_setopt($xh, CURLOPT_POST, 1); 
curl_setopt($xh, CURLOPT_POSTFIELDS, 
      "postvar1=value1&postvar2=value2&postvar3=value3"); 

// in real life you should use something like: 
// curl_setopt($xh, CURLOPT_POSTFIELDS, 
//   http_build_query(array('postvar1' => 'value1'))); 

// receive server response ... 
curl_setopt($xh, CURLOPT_RETURNTRANSFER, true); 

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

// further processing .... 
?> 

Check dies für Ihre Kommentare ... warum seine nicht gültig

<?php 
     $datacamp = array('foo'=>'bar','baz'=>'boom','cow'=>'milk','php'=>'hypertext processor'); 
     echo "<pre>";print_r($datacamp); 
     echo http_build_query(array($datacamp['foo']=>0), '', '&amp;'); 
    ?> 
+0

hi, danke für die Antwort, über diesen Teil http_build_query (array ('postvar1' => 'value1'))); - http_build_query (array ($ datacamp ['active'] => 0))); ist das richtig ? versuchte es zu laufen und sagt Seite funktioniert nicht – ban

+0

nein, es ist falsch. –

+0

http://main.xfiddle.com/31d85a46/test1.php überprüfen Sie dies. –