title: How can i convert a https://graph.microsoft.com/v1.0/me/photo/$value response with php to an image
body: <p>I'm trying to show a Microsoft Graph image on a php website. I receive the image from graph, but its not in the correct format.</p>
  
  <p>The result is like ����JFIF``��C and so on</p>
  
  <p>The problem is that I receive an image as result and not a json. But i'm not able to display the image with the code above.</p>
  
  <pre><code>&gt; HTTP/1.1 200 OK
  Cache-Control: private
  Transfer-Encoding: chunked
  Content-Type: image/jpeg
  ETag: "BB3972DD"
  request-id: 1d3edddb-4278-43ac-be53-4a60861c7703
  client-request-id: 1d3edddb-4278-43ac-be53-4a60861c7703
  x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"North Europe","Slice":"SliceA","Ring":"3","ScaleUnit":"002","Host":"AGSFE_IN_2","ADSiteName":"DUB"}}
  Duration: 176.1934
  Date: Wed, 28 Feb 2018 18:35:52 GMT
  ����JFIF``��C��C����"�� 
  ���}!1A
  </code></pre>
  
  <p>Thanks to the help of this community I was able to solve my problem. My working code is:</p>
  
  <pre><code>$ch = curl_init();
      curl_setopt_array($ch, array(
          CURLOPT_URL =&gt; 'https://graph.microsoft.com/v1.0/me/photo/%24value',
          CURLOPT_HEADER =&gt; false,
          CURLOPT_RETURNTRANSFER =&gt; true,
          CURLOPT_ENCODING =&gt; null,
          CURLOPT_MAXREDIRS =&gt; 10,
          CURLOPT_TIMEOUT =&gt; 30,
          CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
          CURLOPT_HTTPHEADER =&gt; array(
              'authorization: Bearer '.ipDb()-&gt;selectValue('user','hash',array('id' =&gt; ipUser()-&gt;userId())),
              'content-type: image/jpeg; charset=utf-8'
          ) ,
      ));
      $response = curl_exec($ch);
      // Close the cURL resource, and free     system resources
      curl_close($ch);
      $returndata = 'photo &lt;img src="data:image/jpeg;base64,' . base64_encode($response) . '"/&gt;';
      return $returndata;
  </code></pre>