G
G
genesis11112017-02-28 22:56:35
PHP
genesis1111, 2017-02-28 22:56:35

Why doesn't curl work in a loop?

I use yandex direct api.
The cycle consists of only 3 revolutions. With a for loop, only the first one is executed. (Api restrictions - I looked, you can do this, I have a mistake).
Tell me where is she?

for($i=0; $i<=count($result->result->Campaigns)-1; $i++){
  echo '<br>'.$result->result->Campaigns[$i]->Id;	
/////////тут я обозначаю переменные для запроса
$REQUEST = [
            'method' => 'update',
            'params' => [
        'Campaigns' => 
        [
          ["Id"=>"".$result->result->Campaigns[$i]->Id."", 
          "BlockedIps"=>["Items" => [
          "".implode(",",$old_mass).""
          ]]],

        ]

            ]
        ];


$data_string = json_encode($REQUEST);                                                                                   
                                                                                                                     
$ch = curl_init('https://api.direct.yandex.com/json/v5/campaigns');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
        'Accept-Language: ru',
                'Content-Type: application/json; charset=utf-8',
                'Authorization: Bearer '.$myrow[0].'',
                'Client-Login: '.$result->data[0]->Login.''	)
);                                                                                                                   
                                                                                                          
 $result = curl_exec($ch);
curl_close($ch);
  var_dump($result);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2017-02-28
@genezis1111

$result

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question