Thanks for the excellent questions.As first step I would like to create a new "Customer" in ZOHO Invoice any time a new user register on S2Member. Later I'll add the possibility to create a new Invoice any time a user make a payment.
I would use the S2Member API/notification fields, but the ZOHO's API requires this actions to be POST and not GET.
I would try to stick with s2Member's API Notifications on this. You will save yourself some time and everything is better documented for this approach. Trying to use lots of Hooks in this regard can become too complex, and is subject to change slightly in future releases of s2Member.
For instance, you might use s2Member's Signup and Payment Notifications for your needs in this case. For further details, please check your Dashboard here:
s2Member -> API Notifications.
The difference between GET/POST is easy to overcome. If your 3rd party service needs to receive POST data instead of GET, connect s2Member's API Notifications to a proxy script of your own, which receives the GET vars, and POSTs them to your 3rd party service in the way it needs them.
- Code: Select all
<?php
$_3rd_party_service = "http://3rd-party-service.com/api";
$response = curlpsr ($_3rd_party_service, http_build_query (trim_deep (stripslashes_deep ($_GET))));
function trim_deep ($value = FALSE)
{
return is_array ($value) ? array_map ("trim_deep", $value) : trim ((string)$value);
}
function stripslashes_deep ($value = FALSE)
{
return is_array ($value) ? array_map ("stripslashes_deep", $value) : stripslashes ((string)$value);
}
function curlpsr ($url = FALSE, $postvars = array (), $max_con_secs = 20, $max_stream_secs = 20, $headers = array ())
{
if (($url = trim ($url)) && ($c = curl_init ()))
{
if (is_array ($postvars)) $postvars = http_build_query ($postvars);
curl_setopt_array ($c, array (CURLOPT_URL => $url, CURLOPT_POST => true, CURLOPT_CONNECTTIMEOUT => $max_con_secs, CURLOPT_TIMEOUT => $max_stream_secs, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_POSTFIELDS => $postvars, CURLOPT_FOLLOWLOCATION => ($follow = (!ini_get ("safe_mode") && !ini_get ("open_basedir"))), CURLOPT_MAXREDIRS => (($follow) ? 5 : 0), CURLOPT_ENCODING => "", CURLOPT_VERBOSE => false, CURLOPT_FAILONERROR => true, CURLOPT_FORBID_REUSE => true, CURLOPT_SSL_VERIFYPEER => false));
$o = trim (curl_exec ($c));
curl_close($c);
}
return (!empty ($o)) ? $o : false;
}
?>