2014-11-24 34 views
0

我想編寫一個頁面通過PHP捲曲Eventbrite在線上售票重複的事件條目

插入一個事件到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

您兩次執行你的要求:

$result = curl_exec($ch); // 1st 

// Check for errors and display the error message 
if(curl_exec($ch) === false) // 2nd 

更改後者:

if($result === false) 

希望它有幫助。

+0

謝謝,就是這樣! – 2014-11-25 13:36:03