/** * http://documentation.janrain.com/engage/api/auth_info * Extended requires subscription level of Plus or better. */ function engage_auth_info($api_key, $token, $format = ENGAGE_FORMAT_JSON, $extended = ENGAGE_AUTH_EXTEND) { if ($extended === true) { $extended = 'true'; } else { $extended = 'false'; } $ready = true; if (strlen($api_key) != ENGAGE_API_KEY_LEN) { engage_error(ENGAGE_ERROR_APIKEY, __FUNCTION__); $ready = false; } if (strlen($token) != ENGAGE_TOKEN_LEN) { engage_error(ENGAGE_ERROR_TOKEN, __FUNCTION__); $ready = false; } if (!in_array($format, explode(',', ENGAGE_FORMATS))) { engage_error(ENGAGE_ERROR_FORMAT, __FUNCTION__); $ready = false; } if ($ready === true) { $url = ENGAGE_API_BASE_URL . ENGAGE_AUTHINFO_EP; $parameters = array(ENGAGE_KEY_APIKEY => $api_key, ENGAGE_KEY_TOKEN => $token, ENGAGE_KEY_FORMAT => $format, ENGAGE_KEY_EXTEND => $extended); $result = engage_post($url, $parameters); return $result; } return false; }
/** * http://documentation.janrain.com/engage/api/get_contacts * To use get_contacts requires a subscription level of Pro or better. * It is not recommended to use API call as part of sign in. * Users with large numbers of friends will notice the delay. * Setup an asynchronous call to collect this (e.g. iframe or server-side script). */ function engage_get_contacts($api_key, $identifier, $format = ENGAGE_FORMAT_JSON) { $ready = true; if (strlen($api_key) != ENGAGE_API_KEY_LEN) { engage_error(ENGAGE_ERROR_APIKEY, __FUNCTION__); $ready = false; } if (empty($identifier)) { engage_error(ENGAGE_ERROR_IDENT, __FUNCTION__); $ready = false; } if (!in_array($format, explode(',', ENGAGE_FORMATS))) { engage_error(ENGAGE_ERROR_FORMAT, __FUNCTION__); $ready = false; } if ($ready === true) { $url = ENGAGE_API_BASE_URL . ENGAGE_GETCONTACTS_EP; $parameters = array(ENGAGE_KEY_APIKEY => $api_key, ENGAGE_KEY_IDENTIFIER => $identifier, ENGAGE_KEY_FORMAT => $format); $result = engage_post($url, $parameters); return $result; } return false; }
function engage_post($url, $parameters, $ssl = ENGAGE_POST_SSL) { $curl = curl_init(); if ($curl == false) { engage_error(ENGAGE_CURL_ERROR); return false; } engage_error('parameters: ' . print_r($parameters, true), ENGAGE_ELABEL_DEBUG); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_FAILONERROR, true); $result = curl_exec($curl); if ($result == false) { engage_error('Curl error: ' . curl_error($curl)); engage_error('HTTP code: ' . curl_errno($curl)); engage_error('parameters: ' . print_r($parameters, true)); curl_close($curl); } else { curl_close($curl); return $result; } return false; }
function engage_activity_properties($properties_array) { $ready = true; if (!is_array($properties_array) || empty($properties_array)) { engage_error(ENGAGE_ERROR_ARRAY, __FUNCTION__); $ready = false; } if ($ready === true) { return $properties_array; } return false; }