Support

Home Forums Event Espresso Premium ee3 curl API call return 1

ee3 curl API call return 1

Posted: November 27, 2015 at 9:36 am


Shockwave

November 27, 2015 at 9:36 am

Hi,

when i try to open this in my browser:

http://www.sicilykiteschool.it/espresso-api/v1/events/69ron2ppmk/?Datetime.event_start__gt=2015-11-27+17%3A19%3A20

it show me the events, but when i use php cUrl ( CURLOPT_RETURNTRANSFER its true ) it just return 1 without any data…

i cant find why


Josh

  • Support Staff

November 27, 2015 at 10:10 am

Hi there,

Can you post the code you’re using in context in a pastebin or a github gist so someone can take a look at the code?


Shockwave

November 30, 2015 at 2:17 am

$curdate = date(“Y-m-d H:i:s”);
$url = “http://mysite.it/espresso-api/v1/events/”.$ee3->getKey().”.pretty_json?Datetime.event_start__gt=”.urlencode($curdate).”/”;
echo $url.”<br>”;

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false);

$output=curl_exec($ch);

curl_close($ch);
echo print_r($output);

Im using this simple snippet to test the api…. $ee3->getKey() generate an access key ( it works )


Josh

  • Support Staff

November 30, 2015 at 11:54 am

You might try removing the .pretty_json from the URL. Or try this:

https://gist.github.com/joshfeck/20ae85387f34cff253ef


Shockwave

December 4, 2015 at 3:33 am

Hi,

im using your script but it still return just 1… it works well with file_get_content, i cant figure out why cUrl dont.


Josh

  • Support Staff

December 4, 2015 at 5:37 am

It works well with cURL for me.


Shockwave

December 4, 2015 at 6:01 am

oh my bad… now it works… thanks


Josh

  • Support Staff

December 4, 2015 at 6:20 am

You’re welcome.


Shockwave

December 9, 2015 at 7:51 am

Hi again Josh,

there is some example of request that create a registration to an event?


Josh

  • Support Staff

December 9, 2015 at 8:07 am

Hi there,

It’s in the documentation:

https://eventespresso.com/wiki/json-api-add-on/#POST.2FPUT_.2Fregistrations


Shockwave

December 9, 2015 at 8:24 am

Ok so it means that all that data are required?
im trying this but i got “Parsing error. Expected temp-reg1 to be an array”

“body”=>json_encode(array(
“Registrations” => array(
“Event”=>array(
“id” => 1
),
“id”=>”temp-reg1”,
“status”=>”approved”,
“date_of_registration”=>”2015-12-09 14:12:31”,
“final_price”=>0,
“code”=>”1-50c67a6f172e1”,
“url_link”=>null,
“is_primary”=>true,
“is_group_registration”=>false,
“is_going”=>true,
“is_checked_in”=>false,
“Transaction”=>array(
“id”=>”temp-new-one3”,
“timestamp”=>”2015-12-09 14:12:31”,
“total”=>0,
“amount_paid”=>0,
“status”=>”complete”,
“details”=>null,
“tax_data”=>null,
“session_data”=>null,
“payment_gateway”=>”Check”
),
“Attendee”=>array(
“id”=>”temp-new-one2”,
“firstname”=>”fromapi”,
“lastname”=>”fromapiman”,
“address”=>””,
“address2″=>””,
“city”=>””,
“state”=>””,
“country”=>””,
“zip”=>””,
“email”=>”michael@eventespresso.com”,
“phone”=>””
),
)

))


Shockwave

December 9, 2015 at 8:28 am

sorry for bad indentation…. ive created a pastebin


Josh

  • Support Staff

December 9, 2015 at 10:38 am

Yes, the documentation says this:

When submitting this request to create/update the listed registrations, currently ALL fields received on GET /registrations must also be submitted.

I can advise that you follow the example in the documentation closely.

The support post ‘ee3 curl API call return 1’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso