- // Now call "get.php"
- $response = executeWernisApiGet($rows[0], 'data', 'anrede|vorname|name|strasse|plz|ort|birth_day|birth_month|birth_year|email|werber');
-
- // Was the status okay?
- if (isHttpResponseStatusOkay($response)) {
- // API returned non-errous response, 'data=' must be found
- assert(substr($response['response'], 0, 5) == 'data=');
-
- // And remove it, this is now BASE64-encoded
- $encodedData = urldecode(substr($response['response'], 5));
-
- // And decode it (all steps separated to later "easily" debug them)
- $decodedData = base64_decode($encodedData);
-
- /*
- * Do some checks on the decoded string, it should be a
- * serialized array with 11 entries (see above
- * executeWernisApiGet() call).
- */
- assert(substr($decodedData, 0, 6) == 'a:11:{');
- assert(substr($decodedData, -1, 1) == '}');
-
- // The array seems to be fine, unserialize it
- $userData = unserialize($decodedData);
-
- // All mappings WDS66->mailer
- $mappings = array(
- 'anrede' => 'gender',
- 'vorname' => 'surname',
- 'name' => 'family',
- 'strasse' => 'street_nr',
- 'plz' => 'zip',
- 'ort' => 'city',
- 'email' => 'email',
- 'birth_day' => 'birth_day',
- 'birth_month' => 'birth_month',
- 'birth_year' => 'birth_year',
- 'werber' => 'wernis_refid'
- );
-
- // Array for mapped data
- $mappedData = array();
-
- // Map all WDS66 entries into mailer entries
- foreach ($mappings as $from => $to) {
- // All must exist
- if (!isset($userData[$from])) {
- // Element $from does not exist
- reportBug(__FUNCTION__, __LINE__, 'Cannot map from=' . $from . ' -> to=' . $to . ': element does not exist.');
- } // END - if
+ // Has the auth status changed?
+ if ($rows[0]['api_auth_status'] != 'ACCEPTED') {
+ /*
+ * The authorization of this application has been accepted, so
+ * update it and ignore result from function because the update
+ * will always run.
+ */
+ updateWernisRegistrationDataByKey('api_auth_status', 'api_redirect_challenge', $challenge, 'ACCEPTED');
+ } // END - if