Add ability to use either the Space API Key or Project API Key

Created on 13 July 2024, 9 months ago

Problem/Motivation

At the moment the module only supports the global "Space API Key", however, we should also support the more specific "Project API Key".

Proposed resolution

The way that Usersnap handles this in their Wordpress module is by checking the endpoint to see if it exists.

/**
 * Determine which widget type to load.
 * returns the correct URL as string
 */
function get_widget_url($apiKey) {
	$apiUrl = null;
	// try platform
	$headers = get_headers("https://widget.usersnap.com/load/" . $apiKey, 1);
	if ($headers[0] == 'HTTP/1.1 200 OK') {
		$apiUrl = "//widget.usersnap.com/load/" . $apiKey;
	} else
	{
		// try global snippet
		$headers = get_headers("https://widget.usersnap.com/global/load/" . $apiKey, 1);
		if ($headers[0] == 'HTTP/1.1 200 OK') {
			$apiUrl = "//widget.usersnap.com/global/load/" . $apiKey;
		} else {
			// invalidate widget_url since API key cannot be resolved by Usersnap endpoints
			$apiUrl = null;
		}
	}
	return $apiUrl;
}

We could do something similar or make it a setting.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States grndlvl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024