title: Symfony2 curl and api connection
body: <p>I'm new to Symfony and i'm currently toying with API connection. Let me show you the code i'm trying to get to work, the error i get.</p>
  
  <pre><code>/**
  * @Route("/api-test/{MembershipType}/{DisplayName}", name="api-test")
  */
  public function apiTest($MembershipType, $DisplayName)
  {
      $apiKey = 'MY_API_KEY';
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, 'https://www.bungie.net/platform/destiny/'.$MembershipType'/Stats/GetMembershipIdByDisplayName/'.$DisplayName'/');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_HEADER, array('X-API-Key: ' . $apiKey));
  
      $json = json_decode(curl_exec($ch));
      var_dump($json-&gt;Response);
      die;
  }
  </code></pre>
  
  <p>Don't mind the var_dump; and die; parts, it's just for testing. </p>
  
  <p>So the error i get is:</p>
  
  <pre><code>FatalErrorException: Parse: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
  </code></pre>
  
  <p>From what i understand it is caused by the "CURL_URL" part etc. My problem here is, that it seems correct according to documentation and answers to other questions posted here that i've read. Or maybe I'm just wrong.</p>
  
  <p>I would really appreciate it, if someone could give me some tips on what i've done wrong. </p>
  
  <p>EDIT: </p>
  
  <p>Didn't want to make a new question, so i thought i'd ask here again. As mentioned in the answers i was previously missing points in concatenation, but after getting that to work my request only returns null. Any tips on that? ;)</p>
  
  <p>EDIT No.2:</p>
  
  <p>Resolved</p>
  
  <p>instead of:</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_HEADER, array('X-API-Key: ' . $apiKey));
  </code></pre>
  
  <p>it should have been:</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-API-Key: ' . $apiKey));
  </code></pre>