<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Power BI embedded - switch to premium in php application in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/309164#M9119</link>
    <description>&lt;P&gt;Hi there - I'm currently making the switch from Power BI workspace collections to the new model. Previously I used embedded in a PHP application (I'm not a professional PHP developer, though I work with Power BI + BI architecture every day).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, all of the documentation is in c# for ASP.net development.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, I dont wan't to reinvent the wheel, and would need for this to work in PHP which is where our development Minimum Viable Product currently is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code that I used before, which is from an old embedded Microsoft tutorial (which was great!)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will it be possible to amend the code below for the new model, or do I need to start from scratch?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;!--?php &lt;BR /&gt;// 1. power bi access key &lt;BR /&gt;$accesskey = "HIDDEN"; &lt;BR /&gt;// 2. construct input value &lt;BR /&gt;$token1 = "{" . "\"typ\":\"JWT\"," . "\"alg\":\"HS256\"" . "}"; &lt;BR /&gt;$token2 = "{" . "\"wid\":\"HIDDEN\"," . &lt;BR /&gt;// workspace id &lt;BR /&gt;"\"rid\":\"HIDDEN\"," . &lt;BR /&gt;// report id &lt;BR /&gt;"\"wcn\":\"HIDDEN\"," . &lt;BR /&gt;// workspace collection name "\"iss\":\"HIDDEN\"," . "\"ver\":\"0.2.0\"," . "\"aud\":\"https://analysis.windows.net/powerbi/api\"," . "\"nbf\":" . &lt;BR /&gt;date("U") . "," . "\"exp\":" . date("U" , strtotime("+1 hour")) . "}"; &lt;BR /&gt;$inputval = rfc4648_base64_encode($token1) . "." . rfc4648_base64_encode($token2); &lt;BR /&gt;// 3. get encoded signature value &lt;BR /&gt;$hash = hash_hmac("sha256", $inputval, $accesskey, true); &lt;BR /&gt;$sig = rfc4648_base64_encode($hash); &lt;BR /&gt;// 4. get apptoken &lt;BR /&gt;$apptoken = $inputval . "." . $sig; &lt;BR /&gt;// helper functions &lt;BR /&gt;function rfc4648_base64_encode($arg) { $res = $arg; &lt;BR /&gt;$res = base64_encode($res); &lt;BR /&gt;$res = str_replace("/", "_", $res); &lt;BR /&gt;$res = str_replace("+", "-", $res); &lt;BR /&gt;$res = rtrim($res, "="); return $res; } ?--&amp;gt;

&amp;lt;button id="btnView" class="et_pb_contact_submit et_pb_button"&amp;gt;Open Report&amp;lt;/button&amp;gt;
&amp;lt;div id="divView"&amp;gt;&amp;lt;iframe id="ifrTile" width="100%" height="700"&amp;gt;&amp;lt;/iframe&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;script&amp;gt;
        (function () {
          document.getElementById('btnView').onclick = function() {
            var iframe = document.getElementById('ifrTile');
            iframe.src="https://app.powerbi.com/appTokenReportEmbed?reportId=HIDDEN";
            iframe.onload = function() {
              var msgJson = {
                action: "loadReport",
                accessToken: "&amp;lt;?=$apptoken?&amp;gt;",
                height: 500,
                width: 722
              };
              var msgTxt = JSON.stringify(msgJson);
              iframe.contentWindow.postMessage(msgTxt, "*");
            };
          };
        }());
      &amp;lt;/script&amp;gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Nov 2017 21:54:22 GMT</pubDate>
    <dc:creator>insoldev</dc:creator>
    <dc:date>2017-11-22T21:54:22Z</dc:date>
    <item>
      <title>Power BI embedded - switch to premium in php application</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/309164#M9119</link>
      <description>&lt;P&gt;Hi there - I'm currently making the switch from Power BI workspace collections to the new model. Previously I used embedded in a PHP application (I'm not a professional PHP developer, though I work with Power BI + BI architecture every day).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, all of the documentation is in c# for ASP.net development.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, I dont wan't to reinvent the wheel, and would need for this to work in PHP which is where our development Minimum Viable Product currently is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code that I used before, which is from an old embedded Microsoft tutorial (which was great!)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will it be possible to amend the code below for the new model, or do I need to start from scratch?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;!--?php &lt;BR /&gt;// 1. power bi access key &lt;BR /&gt;$accesskey = "HIDDEN"; &lt;BR /&gt;// 2. construct input value &lt;BR /&gt;$token1 = "{" . "\"typ\":\"JWT\"," . "\"alg\":\"HS256\"" . "}"; &lt;BR /&gt;$token2 = "{" . "\"wid\":\"HIDDEN\"," . &lt;BR /&gt;// workspace id &lt;BR /&gt;"\"rid\":\"HIDDEN\"," . &lt;BR /&gt;// report id &lt;BR /&gt;"\"wcn\":\"HIDDEN\"," . &lt;BR /&gt;// workspace collection name "\"iss\":\"HIDDEN\"," . "\"ver\":\"0.2.0\"," . "\"aud\":\"https://analysis.windows.net/powerbi/api\"," . "\"nbf\":" . &lt;BR /&gt;date("U") . "," . "\"exp\":" . date("U" , strtotime("+1 hour")) . "}"; &lt;BR /&gt;$inputval = rfc4648_base64_encode($token1) . "." . rfc4648_base64_encode($token2); &lt;BR /&gt;// 3. get encoded signature value &lt;BR /&gt;$hash = hash_hmac("sha256", $inputval, $accesskey, true); &lt;BR /&gt;$sig = rfc4648_base64_encode($hash); &lt;BR /&gt;// 4. get apptoken &lt;BR /&gt;$apptoken = $inputval . "." . $sig; &lt;BR /&gt;// helper functions &lt;BR /&gt;function rfc4648_base64_encode($arg) { $res = $arg; &lt;BR /&gt;$res = base64_encode($res); &lt;BR /&gt;$res = str_replace("/", "_", $res); &lt;BR /&gt;$res = str_replace("+", "-", $res); &lt;BR /&gt;$res = rtrim($res, "="); return $res; } ?--&amp;gt;

&amp;lt;button id="btnView" class="et_pb_contact_submit et_pb_button"&amp;gt;Open Report&amp;lt;/button&amp;gt;
&amp;lt;div id="divView"&amp;gt;&amp;lt;iframe id="ifrTile" width="100%" height="700"&amp;gt;&amp;lt;/iframe&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;script&amp;gt;
        (function () {
          document.getElementById('btnView').onclick = function() {
            var iframe = document.getElementById('ifrTile');
            iframe.src="https://app.powerbi.com/appTokenReportEmbed?reportId=HIDDEN";
            iframe.onload = function() {
              var msgJson = {
                action: "loadReport",
                accessToken: "&amp;lt;?=$apptoken?&amp;gt;",
                height: 500,
                width: 722
              };
              var msgTxt = JSON.stringify(msgJson);
              iframe.contentWindow.postMessage(msgTxt, "*");
            };
          };
        }());
      &amp;lt;/script&amp;gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Nov 2017 21:54:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/309164#M9119</guid>
      <dc:creator>insoldev</dc:creator>
      <dc:date>2017-11-22T21:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI embedded - switch to premium in php application</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/309613#M9140</link>
      <description>&lt;P&gt;Is it effectively the same, though pointing to a app workspace, rather than a workspace collection?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 09:38:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/309613#M9140</guid>
      <dc:creator>insoldev</dc:creator>
      <dc:date>2017-11-23T09:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI embedded - switch to premium in php application</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/309878#M9147</link>
      <description>&lt;P&gt;Anybody?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 14:56:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/309878#M9147</guid>
      <dc:creator>insoldev</dc:creator>
      <dc:date>2017-11-23T14:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI embedded - switch to premium in php application</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/310370#M9165</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/42364"&gt;@insoldev&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Is it effectively the same, though pointing to a app workspace, rather than a workspace collection?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/42364"&gt;@insoldev&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;No, It is pretty different. They use two sets of REST APIs, not to mentions the SDKs. In the new &lt;A href="https://powerbi.microsoft.com/en-us/blog/power-bi-embedded-capacity-based-skus-coming-to-azure/" target="_self"&gt;Power BI Embedded based on Azure&lt;/A&gt; SKU, it uses the these &lt;A href="https://msdn.microsoft.com/en-us/library/mt147898.aspx" target="_self"&gt;Power BI REST APIs&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to your case, I don't know PHP, however I think below demo in HTML and REST API can work&amp;nbsp;regardless of any coding languages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simply you can embed report in a HTML like.&lt;/P&gt;
&lt;PRE&gt;&amp;lt;html&amp;gt;
&amp;lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;
window.onload = function () { 
  
 // Read embed application token from Model
    var accessToken = "Embedtoken starts with H4sIxxx"; 
	
    // Read embed URL from Model
    var embedUrl = "https://app.powerbi.com/reportEmbed?reportId={reportid}&amp;amp;groupId={groupid}";

    // Read dashboard Id from Model
    var embedReportId = "{reportid}";

    // Get models. models contains enums that can be used.
    var models = window['powerbi-client'].models;	  
	 
    var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId , 
		pageView: "oneColumn",
		settings: {
        filterPaneEnabled: true	
    }		 
    };
    // Get a reference to the embedded dashboard HTML element
    var dashboardContainer = $('#reportContainer')[0] ;
    // Embed the dashboard and display it within the div container.
var report = powerbi.embed(dashboardContainer, config);   
} 
 
&amp;lt;/script&amp;gt; 
 
&amp;lt;div id="reportContainer"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;/html&amp;gt;  &lt;/PRE&gt;
&lt;P&gt;You can get the reportid from the forementioned REST APIs. As to embed token, you can reference &lt;A href="https://community.powerbi.com/t5/Developer/Power-BI-REST-API-using-postman-generate-embed-token/m-p/310153#M9157" target="_self"&gt;my reply in this thread&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 08:04:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/310370#M9165</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-11-24T08:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI embedded - switch to premium in php application</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/313700#M9278</link>
      <description>&lt;P&gt;Thanks Eric - I don't have time to verify, though that is really helpful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 10:47:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-switch-to-premium-in-php-application/m-p/313700#M9278</guid>
      <dc:creator>insoldev</dc:creator>
      <dc:date>2017-11-29T10:47:25Z</dc:date>
    </item>
  </channel>
</rss>

