首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Eventbrite重复事件条目

Eventbrite重复事件条目
EN

Stack Overflow用户
提问于 2014-11-24 13:10:29
回答 1查看 176关注 0票数 0

我试图通过PHP Curl编写一个页面,以便将事件插入eventbrite

经过一些尝试和错误,我已经让它工作,但不是插入一个事件,2是插入。

对此很陌生,非常感谢你的建议.

代码语言:javascript
复制
$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);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-24 13:14:01

您需要执行两次请求:

代码语言:javascript
复制
$result = curl_exec($ch); // 1st

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

将后者改为:

代码语言:javascript
复制
if($result === false)

希望能帮上忙。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27105667

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档