2013-04-29 87 views
1

我已經下載代碼&從「https://github.com/VinceG/USPS-php-api」爲USPS-php-api創建演示。錯誤 - USPS地址驗證PHP API

我有錯誤這樣的「陣列()布爾(真)錯誤:沒有URL集!」

請讓我知道如果您有任何解決方案。

我已經使用下面的代碼。


<?php 
require_once('../USPSAddressVerify.php'); 
$verify = new USPSAddressVerify('xxxxxxxxxxxx'); // I have used correct username 
$address = new USPSAddress; 
$address->setFirmName('Apartment'); 
$address->setApt('100'); 
$address->setAddress('9200 Milliken Ave'); 
$address->setCity('Rancho Cucomonga'); 
$address->setState('CA'); 
$address->setZip5(91730); 
$address->setZip4(''); 

$verify->addAddress($address); 
print_r($verify->verify()); 
print_r($verify->getArrayResponse()); 
var_dump($verify->isError()); 

if($verify->isSuccess()) { 
    echo 'Done'; 
} else { 
    echo 'Error: ' . $verify->getErrorMessage(); 
} 

+0

什麼是在USPSAddressVerify.php中設置的網址? – 2013-04-29 05:04:47

+0

請注意作者在GitHub上的公開問題,其中應該發佈解決方案:https://github.com/VinceG/USPS-php-api/issues/5 – Matt 2013-04-29 05:10:11

+0

我能夠通過註釋掉#行來重新創建錯誤# ''$ opts [CURLOPT_URL] = self :: $ testMode? self :: TEST_API_URL:self :: LIVE_API_URL;'USPSBase.php'中。確保你正在設置'$ opts [CURLOPT_URL]'。 – Sean 2013-04-29 06:06:43

回答

0

我所做的是在USPSBase類,在doRequest方法,註釋掉該行...

$opts[CURLOPT_URL] = self::$testMode ? self::TEST_API_URL : self::LIVE_API_URL 

...並修改此行..

$ch = curl_init(); 

..要...

$ch = curl_init(self::$testMode ? self::TEST_API_URL : self::LIVE_API_URL); 

...,並有可能引起相關的問題,我不得不添加...

$opts[CURLOPT_FOLLOWLOCATION] = !ini_get('open_basedir'); 

... ...後

$opts[CURLOPT_POSTFIELDS] = http_build_query($this->getPostData(), null, '&'); 

...到滿足此警告...

curl_setopt_array(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set 

注意:這隻有已經使用地址驗證功能進行了測試!