1 / 4
Oct 2012

Hello everyone,



It has been some time since I last used my coding "skills", but I'm eager to get back into "the zone" :).



Here's what I'm trying to do. Based on this: 22http://www.e-junkie.com/ej/help.integration.htm22 - I can see that E-Junkie sends some data to my server, according to an URL specified within my product settings. Let's say this URL is "example.com/store"



Now, I'm testing free checkout, which is supposed to send data back to example.com/store, like in case of other payment methods.



I would like to use php CURL to grab the data sent by E-Junkie - I believe it can happen in the background. In the past, I used CURL to send data to specific APIs, but this time it's something new to me, I have to receive, explode, and save data in the background - I guess the server does this without any browser interaction. My basic CURL settings look like this:





// Initiate the curl session

$ch = curl_init();



// Set the URL

curl_setopt( $ch, CURLOPT_POST, $url);



// Allow the headers

curl_setopt($ch, CURLOPT_HEADER, true);



// Return the output instead of displaying it directly

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);



$content = curl_exec($ch);





Here's where I'm a bit lost, I guess due to my years of coding absence. What do I assign to the $url variable? The example.com/store or some E-Junkie URL? Or maybe I should ignore the $url variable at all and set CURLOPT_POST to true?



And how should I explode the $content array (because I believe it's sent as an array) so I can pick up specific variables like buyer's email or e-junkie item number?



Saving everything into database after figuring these things out will be a piece of cake :).

  • created

    Oct '12
  • last reply

    Oct '12
  • 3

    replies

  • 3.1k

    views

  • 3

    users

  • 2

    links

I did, now I know :). I guess reading your documentation isn't the easiest thing to do, I mean, I'm used to php slang in my own language, not in English :P.



For those who might wonder how to grab the data - you use a normal $_POST[variable] to assign variable and you're done.

Ah yes, looking at your earlier inquiry, it looks like you were approaching the matter a bit inside-out. You've apparently sorted it out, but in case anyone else is reading along here:



The CURL utility works as a user agent (like a really stripped-down browser) and would typically be used to retrieve data from a URL (just like loading a Web page) or provide data to the URL by HTTP GET (appending query parameters to the end of the URL you're retrieving) or HTTP POST (like an HTML form submission to the URL).



Our integration method works the other way around, by submitting the data to your script's URL via HTTP POST whenever an order comes in, so your script wouldn't be retrieving the data actively but rather receiving it passively, much like a typical HTML form submission.