2015-09-21 51 views
2

我使用下面的代碼驗證電子郵件地址:驗證貝寶Live賬號

$url = trim("https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus");   

$API_UserName = ""; 
$API_Password = ""; 
$API_Signature = ""; 
$API_AppID = "";          
$API_RequestFormat = "NV"; 
$API_ResponseFormat = "NV"; 

//Create request payload 
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US", 
         "emailAddress" => $email, // email to be validate 
         "matchCriteria" => "NONE" 
        ); 

// convert payload array into url encoded query string 
$body_data = http_build_query($bodyparams, "", chr(38)); 

//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 

$keyArray = explode("&", $response); 

foreach ($keyArray as $rVal) 
{ 
list($qKey, $qVal) = explode ("=", $rVal); 
    $kArray[$qKey] = $qVal; 
} 

if($kArray["responseEnvelope.ack"] == "Success") 
{ 
    // do nothing 
} 
else 
{ 
    // error 
} 

但是這個代碼適用於沙盒帳戶。我爲驗證PayPal帳戶做了哪些更改。 任何幫助將不勝感激。

回答