diff --git a/README.md b/README.md index e209ec8..e04986b 100644 --- a/README.md +++ b/README.md @@ -15,29 +15,38 @@ The samples require the following requirements to run. * [PHP installer](https://windows.php.net/download/) * [Visual Studio Code](https://code.visualstudio.com/download) -* In Visual studio code download the extensions, PHP intelephense and PHP Server. +> **NOTE:** In Visual studio code download the extensions, PHP intelephense and PHP Server. -## Using the PHP sample +## Configuration -* Open the PHP sample's file `index.php` in Visual studio code or any IDE which supports PHP. +* Please ensure you have enabled embed authentication on the `embed settings` page. If it is not currently enabled, please refer to the following image or detailed [instructions](https://help.boldbi.com/site-administration/embed-settings/#get-embed-secret-code) to enable it. -* Please change the following properties in the `index.php` file as per your Bold BI Server. + ![Embed Settings](https://github.com/boldbi/aspnet-core-sample/assets/91586758/b3a81978-9eb4-42b2-92bb-d1e2735ab007) -| **Parameter** | **Description** | -|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **serverUrl** | Dashboard Server BI URL. For Enterprise Edition it should be like - `http://localhost:5000/bi/site/site1` and for Cloud it should be like - `http://dashboard.syncfusion.com/bi`. | -| **dashboardId** | Dashboard Id of the dashboard you want to embed here. | -| **authorizeServerUrl**| URL pointing to AuthorizeServer API. We have a running PHP sample on port 8080. Ex: `http://localhost:8080/rest/authorizeserver.php`. | +* To download the `embedConfig.json` file, please follow this [link](https://help.boldbi.com/site-administration/embed-settings/#get-embed-configuration-file) for reference. Additionally, you can refer to the following image for visual guidance. -* Open the `authorizeserver.php` file and provide the value for below described properties as per your Bold BI server. + ![Embed Settings Download](https://github.com/boldbi/aspnet-core-sample/assets/91586758/d27d4cfc-6a3e-4c34-975e-f5f22dea6172) -| **Parameter** | **Description** | -|---------------|-----------------| -| **secretCode** | Get your EmbedSecret key from the Embed tab by enabling the `Enable embed authentication` on the [Administration page](https://help.boldbi.com/embedded-bi/site-administration/embed-settings/?utm_source=github&utm_medium=backlinks). | -| **userEmail** | UserEmail of the Admin in your Bold BI, which would be used to get the dashboard list. | + ![EmbedConfig Properties](https://github.com/boldbi/aspnet-core-sample/assets/91586758/d6ce925a-0d4c-45d2-817e-24d6d59e0d63) -* Now run the PHP sample to render the particular dashboard. +* Copy the downloaded `embedConfig.json` file and paste it into the designated [location](https://github.com/boldbi/php-sample/tree/master/rest) within the application. Please ensure you have placed it in the application, as shown in the following image. + ![php-embedconfig](https://github.com/user-attachments/assets/cea9eff5-66d9-438b-8c17-45b2bf706229) + +## Run a PHP Sample + + * Open the PHP sample in visual studio code or any respective IDE. + + * Ensure whether embedConfig file is located in following location, `rest/embedConfig.json` and run the PHP application using the respective IDE or using visual studio code. + + * Right-click the `index.php` file and select `PHP Server: Serve project`. + + ![image](https://github.com/user-attachments/assets/8dc49ff7-9d07-4f23-a66f-3d8e0ade03f2) + + * After that application has started, it will display a URL in the command line interface, typically something like (e.g., http://localhost:3000/). Copy this URL and paste it into your default web browser. + + ![image](https://github.com/user-attachments/assets/81230102-1fdd-414a-b6e2-d1e5f519b1f1) + Please refer to the [help documentation](https://help.boldbi.com/embedded-bi/javascript-based/samples/v3.3.40-or-later/php-with-javascript/#how-to-run-the-sample?utm_source=github&utm_medium=backlinks) to know how to run the sample. ## Online Demos diff --git a/index.php b/index.php index 8df030c..59ec93f 100644 --- a/index.php +++ b/index.php @@ -1,33 +1,51 @@ - + - + - -
+ + +
+ \ No newline at end of file diff --git a/rest/authorizeserver.php b/rest/authorizeserver.php index 5c20a66..36ff4b6 100644 --- a/rest/authorizeserver.php +++ b/rest/authorizeserver.php @@ -1,9 +1,19 @@ $dashboardServerApiUrl . $embedDetailsUrl, @@ -50,11 +62,10 @@ function GetEmbedDetails($embedQuerString, $dashboardServerApiUrl){ $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); - return $response; } -//// Prepare embed_Signature by encrypting with secretCode //// +// Prepare embed_Signature by encrypting with secretCode function getSignatureUrl($embedQuerString) { global $secretCode; $keyBytes = mb_convert_encoding($secretCode, 'UTF-8'); diff --git a/rest/getData.php b/rest/getData.php new file mode 100644 index 0000000..283c023 --- /dev/null +++ b/rest/getData.php @@ -0,0 +1,38 @@ + "Could not parse the JSON data.")); + exit(); +} + +// Extract specific values +$clientEmbedConfigData = array( + "DashboardId" => $dataArray["DashboardId"], + "ServerUrl" => $dataArray["ServerUrl"], + "SiteIdentifier" => $dataArray["SiteIdentifier"], + "EmbedType" => $dataArray["EmbedType"], + "Environment" => $dataArray["Environment"], +); + +// Return the specific values of parsed data as JSON response +echo json_encode($clientEmbedConfigData, JSON_PRETTY_PRINT); +?> \ No newline at end of file