如何使用php api检查电子邮件或手机paypal帐户状态?
如何使用php api检查电子邮件或手机paypal帐户状态 好的,如果我想寄钱给这个电子邮件贝宝(如何使用php api检查电子邮件或手机paypal帐户状态?,php,api,paypal,paypal-adaptive-payments,Php,Api,Paypal,Paypal Adaptive Payments,如何使用php api检查电子邮件或手机paypal帐户状态 好的,如果我想寄钱给这个电子邮件贝宝(xxx@xx.com)或手机(1234567890) 在汇款之前,我可以检查xxx@xx.com或1234567890状态帐户例如:活动或不活动是,您可以通过电子邮件或电话号码获取贝宝帐户的状态。为此,您应该使用“GETVERIFIEDSTATUS”API。您必须提供姓名和姓名以及电子邮件/电话。请参考以下链接了解API信息: 除此之外,我还包括了php代码: 使用电子邮件时: $url =
xxx@xx.com
)或手机(1234567890
)
在汇款之前,我可以检查
xxx@xx.com
或1234567890
状态帐户<代码>例如:活动或不活动是,您可以通过电子邮件或电话号码获取贝宝帐户的状态。为此,您应该使用“GETVERIFIEDSTATUS”API。您必须提供姓名和姓名以及电子邮件/电话。请参考以下链接了解API信息:
除此之外,我还包括了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>";
?>
$url=trim(“https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //将PayPal端点设置为sandbox
//$url=修剪(“https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //将PayPal端点设置为Live
$API_UserName=“XXXXXXXXX”//PayPal测试API凭据,如果处于live模式,则将其替换为live
$API_Password=“XXXXXXXX”;
$API_Signature=“XXXXXXXX”;
$API_AppID=“APP-80W284485P519543T”//沙盒的默认应用程序ID,如果处于live模式,则将其替换为live ID
$API_RequestFormat=“NV”;
$API_ResponseFormat=“NV”;
//创建请求负载
$bodyparams=数组(“requestEnvelope.errorLanguage”=>“en_US”,
“电子邮件地址”=>“XXXXXXXXX”,
“firstName”=>“Eshan业务测试”,
“lastName”=>“帐户”,
“匹配条件”=>“名称”
);
//将有效负载数组转换为url编码的查询字符串
$body_data=http_build_query($bodyparams,“,chr(38));
尝试
{
//创建请求并添加标题
$params=array(“http”=>array(
“方法”=>“发布”,
“内容”=>$body\u数据,
“header”=>“X-PAYPAL-SECURITY-USERID:”.$API\u UserName.“\r\n”。
“X-PAYPAL-SECURITY-SIGNATURE:”.$API\U签名。“\r\n”。
“X-PAYPAL-SECURITY-PASSWORD:”.$API\U密码。“\r\n”。
“X-PAYPAL-APPLICATION-ID:.$API\U AppID.\r\n”。
“X-PAYPAL-REQUEST-DATA-FORMAT:”.$API\U RequestFormat.“\r\n”。
X-PAYPAL-RESPONSE-DATA-FORMAT:“.$API\U ResponseFormat”。\r\n”
));
$ctx=stream\u context\u create($params);//创建流上下文
$fp=@fopen($url,“r”,false,$ctx);//打开流并发送请求
$response=stream_get_contents($fp);//get response
//检查流是否打开
如果($response==false)
{
抛出新异常(“php错误消息=”.“$php_errormsg”);
}
fclose($fp);//关闭流
//从响应中解析ap密钥
$keyArray=explode(&,$response);
foreach($keyArray作为$rVal)
{
列表($qKey,$qVal)=分解(“=”,$rVal);
$kArray[$qKey]=$qVal;
}
//出于测试目的,将请求打印到屏幕
回显“标题信息:”。“
”;
打印($params['http']['header']);
回显请求信息:“
”;
打印(urldecode($params['http']['content']);
回显“
”响应:“
”;
//将响应打印到屏幕以进行测试
If($kArray[“responseenevelope.ack”]=“Success”)
{
foreach($kArray作为$key=>$value)
{
echo$key.:“$value.”
;
}
}
其他的
{
foreach($kArray作为$key=>$value)
{
echo$key.:“$value.”
;
}
}
}
捕获(例外$e)
{
echo“Message:||”。$e->getMessage()。“||”;
}
回声“
”;
?>
使用电话号码时:
$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电子邮件,例如:xxxx@xx.com我能检查一下这封邮件的状态吗?贝宝(我能不能寄钱)谢谢你^^你的回答是正确的,你能帮我回答关于贝宝的问题吗