'create', 'api_key' => 'secretkey', //Change this to the api key listed in Convio's backend 'login_name' => 'api_user', // Change this to your Convio username used specifically for Convio API work 'login_password' => 'password', //Change this to your password 'response_format' => 'xml', 'v' => '1.0', // User Information 'primary_email' => 'devnull+test@convio.com', 'name.first' => 'John', 'name.last' => 'Smith', 'user_name' => 'jsmith', 'user_password' => 'df73p54R', // What actions to take on the user when they are created 'source' => 'Test API', 'no_welcome' => 'true' ); //Make a string that can be sent to the API through a post call $param_string = ""; foreach ($params as $name => $value) { $param_string .= "&$name=".urlencode($value); } //Send the data to the Convio API through curl $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $param_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //Get the response back in xml. You can also get the response back //in JSON format if you specify that in the response_format parameter. $xml_response = curl_exec ($ch); $ch_error = curl_error($ch); curl_close($ch); if (is_string($xml_response) && strlen($xml_response)) { // If you got back a response parse the xml and figure out what to do based on the results $p = xml_parser_create(); xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($p, $xml_response, $xml_parser_vals, $xml_parser_pointers); xml_parser_free($p); if (isset($xml_parser_pointers['CREATECONSRESPONSE'])) { // SUCCESS - the user was created in the Convio site. // Parse the xml and add your own business logic here. $id_index = (int)$xml_parser_pointers['CONS_ID'][0]; $message_index = (int)$xml_parser_pointers['MESSAGE'][0]; $id = $xml_parser_vals[$id_index]['value']; $message = $xml_parser_vals[$message_index]['value']; // Save the id here in a local database to be able to sync up with the // Convio site later // ... //Print success message or redirect to another page print("$message"); } else if (isset($xml_parser_pointers['ERRORRESPONSE'])) { // ERROR - the API call did not work as expected. // Parse the xml response and display the error message that was returned by // the API call. $code_index = (int)$xml_parser_pointers['CODE'][0]; $message_index = (int)$xml_parser_pointers['MESSAGE'][0]; $code = $xml_parser_vals[$code_index]['value']; $message = $xml_parser_vals[$message_index]['value']; print("$message
\nerror code: $code"); } } else { // There was some kind of error connecting to the site through curl and you // didn't get back a response - give the end-user an error message. print("There was a problem connecting to $url. ERROR: $ch_error"); } ?>