/** * 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; }
/** * http://documentation.janrain.com/activity * To use activity requires a subscription level of Pro or better. * * You must setup the provider(s) for sharing on the Engage dashboard. * (rpxnow.com - Deployment - Configure Providers) * * The following fields are only used by Facebook and are ignored by other providers: * title, description, action_links, media, properties * * Read more about the Facebook extras at the URL below. * http://developers.facebook.com/docs/guides/attachments * * If more than one media type is included the "media" array Facebook will * choose only one of these types. This is the order Facebook will use to select: * image, flash, mp3 (a.k.a. music) */ function engage_activity($api_key, $identifier, $activity, $location = NULL, $truncate = ENGAGE_TRUNCATE, $url_shortening = ENGAGE_URLSHORT, $prepend_name = ENGAGE_PRENAME) { $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 (!is_array($activity)) { engage_error(ENGAGE_ERROR_ARRAY, __FUNCTION__); $ready = false; } if ($ready === true) { $url = ENGAGE_API_BASE_URL . ENGAGE_ACTIVITY_EP; $activity = json_encode($activity); $parameters = array(ENGAGE_KEY_APIKEY => $api_key, ENGAGE_KEY_IDENTIFIER => $identifier, ENGAGE_KEY_ACTIVITY => $activity, ENGAGE_KEY_TRUNCATE => $truncate, ENGAGE_KEY_URLSHORT => $url_shortening, ENGAGE_KEY_PRENAME => $prepend_name); if ($location !== NULL) { $parameters[ENGAGE_KEY_LOCATION] = $location; } $result = engage_post($url, $parameters); if ($result !== false) { $response = engage_parse_result($result); if (is_array($response)) { if ($response[ENGAGE_KEY_STAT] != ENGAGE_STAT_OK) { engage_error(ENGAGE_ERROR_STAT . $result, __FUNCTION__); return false; } } } return $result; } return false; }