我有如下 curl 请求:
curl -d 'api_user=your_sendgrid_username&api_key=your_sendgrid_password&list=my_list&data[]={"email":"address1@domain.com","name":"contactName1"}&data[]={"email":"address2@domain.com","name":"contactName2"}' https://sendgrid.com/api/newsletter/lists/email/add.json
现在我在帖子中使用以下 php 代码
if(mysql_num_rows($res) > 0) {
$data = array();
while($new_signups = mysql_fetch_assoc($res)){
$data['email'] = $new_signups['uEmail'];
$data['name'] = $new_signups['firstName']." ".$new_signups['lastName'];
}
}
$params = array(
'api_user' => $sengrid_user,
'api_key' => $sendgrid_pass,
'list' =>'TestAlwin',
'data' =>json_encode($data)
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $request);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($ch);
curl_close($ch);
但这只会照顾最后的结果。如何传递上面 curl 请求中给出的更多数据值?或者我需要在循环中运行 curl 传输?