我正在尝试编写一个页面,通过PHP Curl
将事件插入到eventbrite中经过一些试验和错误,我得到了它的工作,但不是插入一个事件,而是插入了2个。
对此非常陌生,非常感谢任何建议/提示......
$token = '######';
$organizerid = '#####';
$timezone = 'Europe/London';
$currency = 'GBP';
$tokenURL = 'https://www.eventbriteapi.com/v3/events/?token='.$token.'&';
$postData = array(
'event.name.html'=>'Curl New Event',
'event.description.html'=>'Test event Eventbrite',
'event.organizer_id'=> $organizerid,
'event.start.utc'=>'2014-11-26T18:00:00Z',
'event.start.timezone'=> $timezone,
'event.end.utc'=>'2014-11-26T19:04:00Z',
'event.end.timezone'=> $timezone,
'event.currency'=> $currency,
'event.venue_id'=>'*****',
'event.online_event'=>'',
'event.listed'=>'',
'event.logo.id'=>'*****',
'event.category_id'=>'',
'event.subcategory_id'=>'',
'event.format_id'=>'',
'event.shareable'=>'on',
'event.invite_only'=>'',
'event.password'=>'',
'event.capacity'=>'25',
'event.show_remaining'=>'on'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $tokenURL);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//need this otherwise you get an ssl error
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
// Check for errors and display the error message
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo $result;
}
curl_close($ch);
答案 0 :(得分:0)
您执行了两次请求:
$result = curl_exec($ch); // 1st
// Check for errors and display the error message
if(curl_exec($ch) === false) // 2nd
将后者改为:
if($result === false)
希望它有所帮助。