title: How to send HTTP Headers and url variables via CURL to Paypal in a 'RequestPermissions' operation?
body: <p>As the title suggest I am trying to make a CURL call to Paypal, but I have come across an error that I believe has to do with the way I am sending my headers via CURL. </p>
  
  <p>In the code example below I am declaring to two arrays with the values Paypal requires to process the request. <code>$headers</code> will be used in the CURL request as the <code>CURLOPT_HTTPHEADER</code>, and <code>$URLvariable</code> will be concatenated with <code>$url</code> and be used as the <code>CURLOPT_URL</code>. </p>
  
  <p>Code Example: </p>
  
  <pre><code>$headers = array(
      'X-PAYPAL-SECURITY-USERID : MYSSANDBOXUSERID',
      'X-PAYPAL-SECURITY-PASSWORD : MYSSANDBOXPASSWORD',
      'X-PAYPAL-SECURITY-SIGNATURE : MYSSANDBOXUSERSIGNATURE',
      'X-PAYPAL-REQUEST-DATA-FORMAT : JSON',
      'X-PAYPAL-RESPONSE-DATA-FORMAT : JSON',
      'X-PAYPAL-APPLICATION-ID : APP-80W284485P519543T'
  );
  
  $URLvariable = array (
          'scope' =&gt; 'EXPRESS_CHECKOUT',
          'callback' =&gt; 'http://vendorpages.info/success.html', 
          'requestEnvelope' =&gt;  '{"errorLanguage":"en_US"}',
  );
  
  foreach ( $URLvariable as $key =&gt; $value ) {
      $URLvariable .= '&amp;' . $key . '=' . urlencode ( $value );
  }
  
  $url = "https://svcs.sandbox.paypal.com/Permissions/RequestPermissions?" . ltrim ( $URLvariable, '&amp;' );
  
  $curl = curl_init ();
  curl_setopt ( $curl, CURLOPT_URL, $url );
  curl_setopt( $curl , CURLOPT_HEADER, true);
  curl_setopt( $curl , CURLOPT_HTTPHEADER, $headers);
  curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 );
  curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, false );
  $result = curl_exec ( $curl );
  curl_close ( $curl );
  $result = urldecode ( $result );
  $result = explode ( '=',$result );
  
  print_r ($result);
  </code></pre>
  
  <p>*Please note I have replaced my Paypal sandbox credentials on purpose. </p>
  
  <p>The output of which is:</p>
  
  <pre><code>Array ( [0] =&gt; HTTP/1.1 400 Bad Request Server: AkamaiGHost Mime-Version: 1.0 Content-Type: text/html Content-Length: 177 Expires: Sat, 08 Feb 2014 09:47:53 GMT Date: Sat, 08 Feb 2014 09:47:53 GMT Connection: close An error occurred while processing your request.
  
  Reference #166.c60300cc.1391852873.2b18ca34 ) 
  </code></pre>
  
  <p>Any constructive help is appreciated...</p>