如何使用 php api 检查电子邮件或手机 paypal 帐户状态?
Posted
技术标签:
【中文标题】如何使用 php api 检查电子邮件或手机 paypal 帐户状态?【英文标题】:How to check email or mobile phone paypal account status using php api? 【发布时间】:2015-06-10 03:05:48 【问题描述】:如何使用php api查看邮箱或手机paypal账号状态?
好的,如果我想汇款到这个邮箱 paypal (xxx@xx.com
) 或手机 (1234567890
)
汇款前,我可以查看xxx@xx.com
或1234567890
状态帐户吗? EG: Active or Not active
【问题讨论】:
Yessss...当然可以! 我尝试做但没有最好的方法。 请发布您的完整内容,您正在尝试完成这项工作? @Testing---如果我有其他用户的paypal电子邮件EG:xxxx@xx.com我可以检查这个电子邮件paypal的状态(我可以汇款或不汇款) 【参考方案1】:是的,您可以通过电子邮件或电话号码获取 PayPal 帐户的状态。为此,您应该使用“GETVERIFIEDSTATUS”API。您必须提供名字和姓氏以及电子邮件/电话。请参考以下链接获取 API 信息:
https://developer.paypal.com/webapps/developer/docs/classic/api/adaptive-accounts/GetVerifiedStatus_API_Operation/#id098QF50F04Y
除此之外,我还包含了 php 代码:
使用电子邮件时:
$url = trim("https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //set PayPal Endpoint to sandbox
//$url = trim("https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //set PayPal Endpoint to Live
$API_UserName = "XXXXXXXXX"; //PayPal Test API Credentials, Replace it with live if in live mode
$API_Password = "XXXXXXXX";
$API_Signature = "XXXXXXXX";
$API_AppID = "APP-80W284485P519543T"; //Default App ID for Sandbox, replace it with live id if in live mode
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"emailAddress" =>"XXXXXXXXX",
"firstName" =>"Eshan Business TEST",
"lastName" =>" Account",
"matchCriteria" => "NAME"
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT:" . $API_ResponseFormat . "\r\n"
));
$ctx = stream_context_create($params); //create stream context
$fp = @fopen($url, "r", false, $ctx); //open the stream and send request
$response = stream_get_contents($fp); //get response
//check to see if stream is open
if ($response === false)
throw new Exception("php error message = " . "$php_errormsg");
fclose($fp); //close the stream
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal)
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
//print the request to screen for testing purposes
echo "Header info:" . "<br>";
print_r($params['http']['header']);
echo "<br><br>" . "Request Info:" . "<br>";
print_r(urldecode($params['http']['content']));
echo "<br><br>" . "Response:" . "<br>";
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success")
foreach ($kArray as $key =>$value)
echo $key . ": " .$value . "<br/>";
else
foreach ($kArray as $key =>$value)
echo $key . ": " .$value . "<br/>";
catch(Exception $e)
echo "Message: ||" .$e->getMessage()."||";
echo "<br>";
?>
使用电话号码时:
<?php
$url = trim("https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //set PayPal Endpoint to sandbox
//$url = trim("https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //set PayPal Endpoint to Live
$API_UserName = "XXXXXXXXXXXX"; //PayPal Test API Credentials, Replace it with live if in live mode
$API_Password = "XXXXXXXXXXXX";
$API_Signature = "XXXXXXXXXXX";
$API_AppID = "APP-80W284485P519543T"; //Default App ID for Sandbox, replace it with live id if in live mode
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"accountIdentifier.mobilePhoneNumber" =>"4088359375",
"firstName" =>"Eshan Personal Test",
"lastName" =>" Account",
"matchCriteria" => "NAME"
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT:" . $API_ResponseFormat . "\r\n"
));
$ctx = stream_context_create($params); //create stream context
$fp = @fopen($url, "r", false, $ctx); //open the stream and send request
$response = stream_get_contents($fp); //get response
//check to see if stream is open
if ($response === false)
throw new Exception("php error message = " . "$php_errormsg");
fclose($fp); //close the stream
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal)
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
//print the request to screen for testing purposes
echo "Header info:" . "<br>";
print_r($params['http']['header']);
echo "<br><br>" . "Request Info:" . "<br>";
print_r(urldecode($params['http']['content']));
echo "<br><br>" . "Response:" . "<br>";
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success")
foreach ($kArray as $key =>$value)
echo $key . ": " .$value . "<br/>";
else
foreach ($kArray as $key =>$value)
echo $key . ": " .$value . "<br/>";
catch(Exception $e)
echo "Message: ||" .$e->getMessage()."||";
echo "<br>";
?>
【讨论】:
谢谢你^^你的回答是正确的,请你给我一些关于paypal的问题my question link以上是关于如何使用 php api 检查电子邮件或手机 paypal 帐户状态?的主要内容,如果未能解决你的问题,请参考以下文章
使用 PHP 检查邮件是不是订阅 MailChimp API 3.0 中的列表
如何使用 Google Mail API 检查邮件是不是被标记为“重要”?