php - Curl Post with a Loop (Field taken from a DB) -


i need help.

actually i'm doing curl post x-wsse auth , posting 2 arguments, id , phone. ok.

now need pass list of id , phones. in way can this? post file directly? using loop?

i have csv file, simplify upload file on db, can take directly there.

this actual code.

<?php  function make_nonce() { $chars = "123456789abcdefghijklmnopqrstuvwxyz"; $random = "" . microtime(); $random .= mt_rand(); $mi = strlen($chars) - 1; ($i = 0; $i < 10; $i++) {     $random .= $chars[mt_rand(0, $mi)]; } $nonce = md5($random); return $nonce; }  function make_token($username, $password) { $nonce = make_nonce(); $ts = date ( 'y-m-d\th:i:sp', time() + 290 ); $digest = base64_encode(sha1($nonce.$ts.$password, true)); return sprintf('usernametoken username="%s",  passworddigest="%s",nonce="%s",   created="%s"',                $username, $digest, $nonce, $ts); }   $token =  make_token("username", "password"); // ### genero il token   $headers = array( 'content-type: application/x-www-form-urlencoded;      charset=utf-8','accept-charset : utf-8', 'x-wsse :' . $token);   $ch = curl_init();  curl_setopt($ch, curlopt_url,'http://url'); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_header, true); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields,         "phonenumber=38452136&idpratica=745");  curl_exec ($ch);    var_dump($ch);   curl_close ($ch);      ?> 

i have list of 1000 phonenumber , relatives idpratica (id).

what can do?

i know way doing 1 record.

$fields = array(      'phonenumber' => '38452136',     'idpratica' => '745' );  //url-ify data post foreach($fields $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); 

and use

curl_setopt($ch,curlopt_post, count($fields)); curl_setopt($ch,curlopt_postfields, $fields_string); 

please me


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -