Need your help with PayPal api:
Error: HTTP/1.1 404 Not Found Server: Apache-Coyote/1.1 PROXY_SERVER_INFO: host=slcsbjava3.slc.paypal.com;threadId=279 Paypal-Debug-Id: 939f47a2217c8 SERVER_INFO: paymentsplatformserv:v1.payments.payment&CalThreadId=336&TopLevelTxnStartTime=147dcf033b3&Host=slcsbjm1.slc.paypal.com&pid=25157 Content-Language: * Date: Sat, 16 Aug 2014 03:50:35 GMT Content-Type: application/json Content-Length: 207 {"name":"INVALID_RESOURCE_ID","message":"The requested resource ID was not found","information_link":" https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID ","debug_id":"939f47a2217c8"}
Code PHP:
define("URI_SANDBOX", "https://api.sandbox.paypal.com/v1/");
$url = URI_SANDBOX . "payments/payment/PAY-6PU626847B294842SKPEWXHY"; //PAY - correct!!!
$ch = curl_init($url);
$auth_token = "zzzzzzzz"; //correct
$headers = array("Content-Type:application/json", "Authorization:Bearer ".$auth_token);
$options = array(
CURLOPT_HEADER => true,
CURLINFO_HEADER_OUT => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => true,
CURLOPT_TIMEOUT => 10
);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
print_r($response);
curl_close($ch);
You could try something like...
<?php
$ch = curl_init();
$clientId = "myId";
$secret = "mySecret";
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId.":".$secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
$result = curl_exec($ch);
if(empty($result))die("Error: No response.");
else
{
$json = json_decode($result);
print_r($json->access_token);
}
curl_close($ch);
?>
You can read more: https://devtools-paypal.com/guide/pay_paypal/curl?env=sandbox
<?php
$pay = "PAY-8YH60661WV8858705LJ4YKWY";
$ch = curl_init();
$auth_token = "your token id";
$headers = array("Content-Type:application/json", "Authorization:Bearer ".$auth_token);
$options = array(
CURLOPT_URL => "https://api.sandbox.paypal.com/v1/payments/payment/".$pay,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$json = json_decode($result);
echo (json_encode($json));
curl_close($ch);
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.