I can't figure out what I'm doing wrong here. Can someone take a look at this code and tell me why NOTHING is being returned?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $eurl);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $authstr);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); // Do not return headers
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml", 'Content-Length: ' . strlen($parameter)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // If you set this to 0, it will take you to a page with the http response
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$return = curl_exec($ch);
$xml = simplexml_load_string($return);
I've finally got *something* going here.
I output my xml string: $return = curl_exec($ch);
Then put it into a SimpleXML variable.
$xml = new SimpleXMLElement($return);
Now I can parse it, using this, for instance:
which returns back the correct string: Constant Contact
However, I can't parse ANYTHING inside of the entry->content node.
Nothing gets sent back.
Why not? Any ideas?
I was looking at your code when you went "bump," but hadn't found the issue. I am going to try to troubleshoot the code you just provided to see if I can find the reason it's not returning anything, but it just might take some time (just as I suspect it is on your side as well). I will post back here with updates.
API Support Specialist
Would love to see a print_r of the return variable to see exactly what we are working with that needs to be parsed out. If you could post that here, that would be great.
We have a PHP lib that would lighten the work load you have to deal with such as XML parsing and cURL which can be found here: https://github.com/constantcontact/ctct_php_library
You just include one file in your project and your ready.
Let us know how you want to proceed and we can continue looking at your cURL settings and assist with parsing out the return.