title: Paypal use of clientid & clientSecret for PHP
body: <p>I am using Paypal API for a long time for developing.</p>
  
  <p>Now, my site is on life, and I have problems, of migrating my code to life,
  and I presume that I need add clientid+clientSecret, which I didn't have on developing site.</p>
  
  <p>(As I see on <a href="https://github.com/paypal/rest-api-sdk-php" rel="nofollow">https://github.com/paypal/rest-api-sdk-php</a> and by some workarround).</p>
  
  <p>Also, I want minimal changes on the code bellow, even it seems old fashioned to have it worked in life web site.</p>
  
  <p>As developer, I use "setExressCheckout" method like this
  (Attention to echo $response - I don't expect that line. What to do instead?)</p>
  
  <p>// =========== START OF CODE</p>
  
  <pre><code>&lt;?php
  
  /*.
  require_module 'standard';
      require_module 'standard_reflection';
      require_module 'spl';
      require_module 'mysqli';
      require_module 'hash';
      require_module 'session';
      require_module 'streams';
  .*/
  
      require_once __DIR__ . "/stdlib/all.php";
  
  /*. array .*/ $body_data = null;
  
  $body_data_txt = "";
  
  /*. string .*/ $htmlpage  = "";
  
  /*. array .*/ $tokenAr = array();
  
  $response = "";
  
  session_start();
  
  $url = trim('https://www.sandbox.paypal.com/cgi-bin/webscr');
  
  $body_data = array( 'USER' =&gt; "*******",
                      'PWD' =&gt; "*******",                                    
                      'SIGNATURE' =&gt; "******",
                      'VERSION' =&gt; "95.0",
                      'PAYMENTREQUEST_0_PAYMENTACTION' =&gt; "Sale",
                      'PAYMENTREQUEST_0_AMT' =&gt; (string)$_SESSION["AMOUNT"],
                      'PAYMENTREQUEST_0_CURRENCYCODE' =&gt; 'USD',
                      'RETURNURL' =&gt; "*****",
                      'CANCELURL' =&gt; "******",
                      'METHOD' =&gt; "SetExpressCheckout"
                                  );
  
  $body_data_txt = http_build_query($body_data, '', chr(38));
  try
  {
      //create request and add headers
      $params = array(
          'http' =&gt; array(
              'protocol_version' =&gt; "1.1",
              'method' =&gt; "POST",
              'header' =&gt; "".
              "Connection: close\r\n".
              "Content-Length: ".strlen($body_data_txt)."\r\n".
              "Content-type: "."application/x-www-form-urlencoded"."\r\n",
              'content' =&gt; $body_data_txt
      ));
  
      //create stream context
       $ctx = stream_context_create($params);
  
      //open the stream and send request
      try {
          $fp = fopen($url, 'r', false, $ctx);
      } catch(ErrorException $e) {
          throw new ErrorException("cannot open url" . $url . " error:" . $e-&gt;getMessage());
      }
       //get response
       $response = (string)stream_get_contents($fp);
       //check to see if stream is open
       if ($response === "") {
          throw new Exception("php error message = " . "$php_errormsg");
       }
  
       //close the stream
       fclose($fp);   
  
       $key = explode("&amp;", $response);
       if (substr($response, 0, 1) === "&lt;") {
          echo $response; // ******************************
       }
       ....
  </code></pre>
  
  <p>// ============ END OF CODE</p>
  
  <p>The code doesn't work as expected, since the line 'echo $response ...' should not run.
  It has the contents of a screen titled: </p>
  
  <p>"No buyers or sellers </p>
  
  <p>Sign up for free.</p>
  
  <p>...
  "</p>
  
  <p>As I investigated, I need client-id and client-secret. That I made on <a href="https://developer.paypal.com" rel="nofollow">https://developer.paypal.com</a>.
  But how to use it - with minimal changes on my code?</p>
  
  <p>Thanks :)</p>