如何使用php api检查电子邮件或手机paypal帐户状态? [英] How to check email or mobile phone paypal account status using php api?

查看:26
本文介绍了如何使用php api检查电子邮件或手机paypal帐户状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用php api查看邮箱或手机paypal账户状态?

How to check email or mobile phone paypal account status using php api ?

好的,如果我想汇款到这个电子邮件贝宝(xxx@xx.com)或手机(1234567890)

OK, If i want to send money to this e-mail paypal (xxx@xx.com) or mobile phone (1234567890)

在汇款之前,我可以检查xxx@xx.com1234567890 状态帐户.EG:活动或不活动

Before send money, can i check xxx@xx.com Or 1234567890 status account. EG: Active or Not active

推荐答案

是的,您可以通过电子邮件或电话号码获取 PayPal 帐户的状态.为此,您应该使用GETVERIFIEDSTATUS"API.您必须提供名字和姓氏以及 email/phone .请参考以下 API 信息链接:

Yes you can get the status of the PayPal account either by email or the phone number. You should the "GETVERIFIEDSTATUS" API for this purpose . You will have to provide the first and the last name along with email/phone . Kindly refer the below link for API info :

https://developer.paypal.com/webapps/developer/docs/classic/api/adaptive-accounts/GetVerifiedStatus_API_Operation/#id098QF50F04Y

除此之外,我还包含了 php 代码:

Apart from that I have included the the php code :

使用电子邮件时:

  $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>";  
?>

这篇关于如何使用php api检查电子邮件或手机paypal帐户状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆