setExternalId
Beschreibung
Jedem Allyve-Nutzer kann eine externe Nutzer-ID mitgegeben werden, welche bei allen folgenden Logins des Nutzers mitgeliefert wird, um ein einfaches Mapping zur Datenbank der Consuming-Party zu erlauben.
Kommunikation zwischen
Consuming-Party Backend > allyve Backend
Request-URL
/api/sociallyve/protected/user/externalid
Methoden-Typ
POST
Request-Parameter
| Feld | Beschreibung |
|---|---|
| provider | Der angefragte Provider als Stringkonstante. Eine Liste der unterstützten Provider finden Sie unter "Provider" |
| uid | Die ID des Nutzers beim betroffenen Provider. |
| externalid | Die von der Consuming-Party vergebene Nutzer-ID, die dem Sociallyve-Account zugeordnet werden soll. |
allyve-Backendaktivität
Persistieren/aktualisieren der, von der Consuming-Party vergebenen Nutzer-ID für einen allyve Nutzer
Response
HTTP-STATUS
Response-Parameter
keine
Mögliche Http Error Codes
| HTTP Code | Beschreibung |
|---|---|
| 404 | Der angegebene Benutzer wurde nicht gefunden. |
| 500 | Fehler beim Zugriff auf die Datenbank. |
Code-Beispiel: PHP
//Your application's credentials for using the API $myAppKey = '12345678910111213'; $myAppSecret = 'IWillNeverTellThisToAnyone'; //Set the correct API URL to use $apiUrl = 'https://api.allyve.com/api/sociallyve/protected/user/externalid'; //construct an array with all the neccessary parameters needed for the request to the API $params["timestamp"] = time(); $params["applicationid"] = $myAppKey; $params["provider"] = 'facebook'; $params["uid"] = 'userIdAtFacebook'; $params["externalid"] = 'DarthVader'; //sort the parameters array alphabetically by the array keys ksort($params); //construct a temporary array, that will hold concatinated keys and values of the parameter array (key=value) $tempArray = array(); //walk over the parameter array and combine each key and value foreach ($params as $key => $value) { $tempArray[] = $key . "=" . $value; } //construct a properly formatted querystring from the combined key/values $queryStringUnsigned = implode("&", $tempArray); //construct the signature $querySignature = base64_encode(hash_hmac("sha1", $queryStringUnsigned, $myAppSecret, true)); //append the signature to the unsingend query string $queryStringSigned = $queryStringUnsigned . "&signature=" . urlencode($querySignature); //let's call the API with the help of CURL $curl = curl_init($apiUrl); curl_setopt ($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); //If you do not have alredy set up a CA cert bundle in PEM format uncomment the next line, BUT YOU SHOULD NOT DO THAT IN PRODUCTION //curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); //If you have a CA cert bundle set the path to it (http://curl.haxx.se/docs/caextract.html) $pathToMyCertBundle = getcwd().'/cacert.pem'; curl_setopt($curl, CURLOPT_CAINFO, $pathToMyCertBundle); curl_setopt($curl, CURLOPT_POSTFIELDS, $queryStringSigned); curl_exec($curl); $info = curl_getinfo($curl); curl_close($curl); if (is_array($info) && isset($info['http_code']) && $info['http_code'] == 200) { echo 'ok'; } else { echo 'error'; }
Weiterführende Informationen
Zuletzt aktualisiert am 5. März 2012 von admin - Anmelden
