Posted to API Forum
15 comments
-
Permanently deleted user Is there a way to retrieve all event_names with 1 call?
-
Main Office I am using the PHP library from GitHub. I am just getting started with it. I am getting 401 status codes when using the /demo/index.php file. I have the apiToken, secretKey, and buyerId plugged in and I did not make any other changes to the file. The Zend Framework is in the correct path. Should the drop down menu's with the different methods be working already? or is there something else I need to do?
-
Permanently deleted user @Maribel @MoanoloConde I just re-tested the demo file and it is working OK for me. Try changing the URL from the sandbox one to the production one and see if that works for you. There have been a few incidents where people's credentials were working OK on production but not in the sandbox.
-
Main Office I changed from sandbox to production. Now I get status code:404 and other errors depending on the method I choose one example below:
Parse error: syntax error, unexpected T_FUNCTION in /library/Ticketevolution/Webservice/ResultSet.php on line 224
-
Main Office To clarify: "showEvent" method give me status code 404. "listEvents" method give me:
Parse error: syntax error, unexpected T_FUNCTION in /library/Ticketevolution/Webservice/ResultSet.php on line 224
-
Permanently deleted user @Maribel My apologies. I just pushed a small revision that makes the demo app work a lot better. It should fix your 401 error when doing listEvents().
I believe your 404 error for showEvent() is because the supplied event_id was invalid. Make sure the event_id you enter is a valid one (136957 should work) and try it again.
Any time you request a non-existent item such as a user, event, brokerage you will get a 404 response.
-
Main Office I have downloaded the updated /demo/index.php file. The 'showEvent' method works with the EventID you provided. The 'listEvents' method is still giving me the same error:
Parse error: syntax error, unexpected T_FUNCTION in /library/Ticketevolution/Webservice/ResultSet.php on line 224
I haven't made any changes to file except plugging in the apiToken, secretKey, and buyerId. The options that are being passed to the 'listEvents' method are:
*Options:
page = 1
per_page = 10 * -
Permanently deleted user Is the /library/Ticketevolution up to date as well? I haven’t been able to reproduce the error.
-
Main Office Yes the /library/Ticketevolution folder files are the latest version. I am still getting the same error. The error occurs with every 'list(*)' method. The error is referring to the functions that handle excluding or having only exclusive results. Lines 224, 226, 250, 252 in ResultSet.php .
-
Permanently deleted user Are you using PHP 5.2 by any chance? This line uses anonymous functions which were added to PHP in 5.3.
-
Main Office Yes you are right I am using php 5.2 which I just found out does not support anonymous functions. Is there a way around this?
-
Permanently deleted user I would really suggest upgrading to 5.3 if possible, but if that isn’t an option you could either delete those lines and not use excludeResults() and exclusiveResults() or you could try re-writing those methods to use create_function() instead.
-
Main Office Upgrading to 5.3 is not an option with my server company. I have removed the lines with the 'exclude' and 'exclusive' functions. There is still another anonymous function near line 335:
protected function _usortByMultipleKeys($key, $direction=SORT_ASC)
{
$sortFlags = array(SORT_ASC, SORT_DESC);
if(!in_array($direction, $sortFlags)) {
throw new InvalidArgumentException('Sort flag only accepts SORT_ASC or SORT_DESC');
}return function($a, $b) use ($key, $direction, $sortFlags) {
This last line I've pasted is the one giving me the trouble. Can you rewrite this part so that it can work with php 5.2? I have not been able to figure out how to convert it using create_function(). I've looked for examples online, but none are giving me any luck.
-
Main Office Actually never mind, I think I just figured it out. Code below:
return create_function('$key, $direction, $sortFlags', '
if(!is_array($key)) { //just one key and sort direction
if(!isset($a->$key) || !isset($b->$key)) {
throw new Ticketevolution_Webservice_Exception("Attempting to sort on non-existent keys");
}
if($a->$key == $b->$key) {
return 0;
}
return ($direction==SORT_ASC xor $a->$key < $b->$key) ? 1 : -1;
} else { //using multiple keys for sort and sub-sort
foreach($key as $sub_key => $sub_asc) {
//array can come as "sort_key"=>SORT_ASC|SORT_DESC or just "sort_key", so need to detect which
if(!in_array($sub_asc, $sortFlags)) {
$sub_key = $sub_asc;
$sub_asc = $direction;
}
//just like above, except "continue" in place of return 0
if(!isset($a->$sub_key) || !isset($b->$sub_key)) {
throw new Ticketevolution_Webservice_Exception("Attempting to sort on non-existent keys");
}
if($a->$sub_key == $b->$sub_key) {
continue;
}
return ($sub_asc==SORT_ASC xor $a->$sub_key < $b->$sub_key) ? 1 : -1;
}
return 0;
}
'); -
Permanently deleted user Glad to hear you’re getting it worked out.
I would definitely put moving hosts (or getting yours to upgrade to 5.3) on your roadmap. PHP 5.3 has been out for 2 years now and 5.2 is no longer supported by PHP.net.
Also, I'm updating the docs for the library to indicate 5.3 as a minimum version.