- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Having trouble with PHP sample code for CIM
I've done programming for Authorize.net in the past without any problems, but I wanted to take a look at CIM in the sandbox today. I'm having trouble with the PHP sample code. I entered the login id and transaction key into vars.php, but when I try to run profile_create.php, the only response I get back is "The operation failed with the following errors:" (with nothing listed afterwards).
I'm running this on a test server that has a copy of our production code on it that works fine, so it shouldn't be a problem with the server setup.
โ08-25-2015 03:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I've changed it to use curl instead of fsockopen, and I'm actually getting some stuff back now.
โ08-26-2015 08:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
However the XML parsing isn't working because the response contains more than just XML. So much for useful sample code...
โ08-26-2015 09:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This works:
function parse_api_response($content) { $content = substr($content, strpos($content, "<")); // strip out header lines $parsedresponse = simplexml_load_string($content, "SimpleXMLElement"); if ("Ok" != $parsedresponse->messages->resultCode) { echo "The operation failed with the following errors:<br>"; foreach ($parsedresponse->messages->message as $msg) { echo "[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text) . "<br>"; } echo "<br>"; } return $parsedresponse; }
โ08-26-2015 10:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
Check out the new PHP samle code on github, it's still work-in-progress but here are the CIM samples: https://github.com/AuthorizeNet/sample-code-php/tree/master/CustomerProfiles
You can see they are also matched with our API explorer http://developer.authorize.net/api/reference/index.html#manage-customer-profiles
Hope this helps,
Brian
โ08-27-2015 01:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. I tried that and found it to also have problems.
I then found this, which seems to work pretty well:
http://www.johnconde.net/blog/tutorial-integrate-authorize-net-xml-api-universal-php-class/
โ09-03-2015 03:10 PM

