To get the access token we need to make a POST request to with our PayPal application’s client_id and secret.api.sandbox.paypal.com/v1
$curl = curl_init(); $url = "https://api.sandbox.paypal.com/v1/oauth2/token"; $clientId = "your client Id"; $secret = "your secret key"; curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "grant_type=client_credentials", CURLOPT_USERPWD => $clientId.":".$secret, CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded"),) ); $result = curl_exec($curl); curl_close($curl); $response = json_decode($result, true); echo $response['access_token'];