Shalini
Shalini

Reputation: 104

Use of curl Paypal API in php

How to use the curl function in php for implementing paypal

The curl code is below

curl https://api.sandbox.paypal.com/v1/oauth2/token \

-H "Accept: application/json" \

-u "AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd:EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX" \

-d "grant_type=client_credentials"

How to implement in php with curl ?

Please help

Upvotes: 0

Views: 461

Answers (1)

Chilion
Chilion

Reputation: 4490

First of all, check it out @ PHP.net

Second, you will have to use setopt for the -H, -u, -d options.

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");

//Here you will have to add your options, I think this code will bring you far :-)
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
?>

Upvotes: 1

Related Questions