I am not sure that this is a problem of Matomo or my own ignorance about the use of PHP. I am posting it in order to clarify the matter.
BACKGROUND: I have no trouble communicating with the Matomo reporting API to extract desired bits of information about my visitors that I then share with my visitors on a page that I call the Looking Glass. This is achieved with an AJAX call using a JSON type response variable and a PHP cURL request file. The beauty of this mechanism is that I do not have to expose my authorization token to the general public, but can still display Matomo report contents without having to make all information potentially available to Matomo users via the autonomous user setting in the Matomo administrative panel.
This method of reporting runs into trouble, however, when I try to take advantage of Matomo’s well-constructed widgets. Please find below the strategy that fails and comment when and where possible.
Create an iframe in an HTML document whose src attribute points to a PHP file that makes a call to the Matomo reporting API and requests a widget.
RESULT SET (See Images):
DESIRED RESULT (A Working Widget With Full Functionality)
What follows is a direct embed of the same URL via the src attribute of a custom iframe. This widget is totally functionable.