2015-12-08 67 views
0

我的錯誤是這樣的,我有這個變量:與file_get_content獲取數據

$request = "https://xxxxx.xxx.com/2/delivery/request?"; 
    $request.= "api_key=".$api_key."&"; 
    $request.= "user_id=".$user_id."&"; 
    $request.= "deliveery_type=".$delivery_type."&"; 
    $request.= "route=E.+Pallares+y+&"; 
    $request.= "street_number=110&"; 
    $request.= "neighborhood=San Lucas&"; 
    $request.= "locality=Distrito&"; 
    $request.= "administrative_area_level_1=Distrito&"; 
    $request.= "postal_code=04030&"; 
    $request.= "country=Mexico&"; 
    $request.= "latlng=".$latlng."&"; 
    $request.= "destination-route=".$destination_route."&"; 
    $request.= "destination-street_number=&"; 
    $request.= "destination-neighborhood=&"; 
    $request.= "destination-locality=".$destination_locality."&"; 
    $request.= "destination-administrative_area_level=".$destination_administrative_area_level."&"; 
    $request.= "destination-postal_code=".$destination_postal_code."&"; 
    $request.= "destination-country=Mexico&"; 
    $request.= "destination-latlng=".$d_latlng."&"; 
    $request.= "customer_email=".$customer_email."&"; 
    $request.= "customer_phone=".$customer_phone."&"; 
    $request.= "notification_email=&"; 
    $request.= "notes=".$notes."&"; 
    $request.= "dispatch=True"; 

的file_get_contents($要求);

所有這些變量都自動填寫,但是當我用的file_get_contents運行這個答案是這樣的:

Warning: file_get_contents(https://xxxxx.xxx.com/2/delivery/request?api_key=23894thfpoiq10fapo93fmapo&user_id=5744125&deliveery_type=Programado&route=E.+Pallares+y&street_number=110&neighborhood=San Lucas&locality=Distrito+Federal&administrative_area_level_1=Distrito+Federal&postal_code=04030&country=Mexico&latlng=19.346%2C-99.154&destination-route=Pallares+y+Portillo+181+Casa+5%2CParque+San&destination-street_number=&destination-neighborhood=&destination-locality=Coyoacan&destination-administrative_area_level=Distrito+Federal&destination-postal_code=04030&destination-country=Mexico&destination-latlng=19.365%2C-99.1966&customer_email=saul%4099minutos.com&customer_phone=5554&notification_email=&notes=Orden%3A+%231019%2C+Cliente%3A+Ricardo+Torreblanca%2C+Productos%3A+Paquete+Blackmore+ONE+%5Bincluye+1+cafetera+en+comodato+%2B+60+c%C3%A1psulas+mensuales%2C+durante+12+mes in 
/home/public_html/shopify/shipping_test.php on line 1301 
在我的error_log

我檢查,我看到的網址是完整的,但我不知道爲什麼這些錯誤

+0

呀,你一定要來urlencode(),這些值對每個PARAM。您不能將未編碼的電子郵件放入獲取字符串中(@符號)。 (下) –

+0

該警告有點奇怪,它看起來像你urlencoded整個得到字符串... –

回答

0

我想你會希望來urlencode每個參數/值段值作爲:

$request = "https://www.site.tld/path/to/api?param=" . urlencode($value); 

...等。

+0

在代碼的最後我忘了寫file_get_contents($ request);通過這種方式,當我運行我的代碼時,我有警告 – victor

+0

您仍然需要單獨對每個參數值進行urlencode編碼。您正在發送電子郵件。我們知道至少有一個價值正在打破。 –