【问题标题】:Send url when its done完成后发送网址
【发布时间】:2015-05-07 23:21:43
【问题描述】:

我想在构建它之后发送一个 url。这是到目前为止的代码。

   $producten = '';
   foreach ($orders as $product) {
       $producten .= "&articlecode=" . $product['productTitle'] . "&color=NAVY&size=" . $product['variantTitle'] . "&qty=" . $product['quantityOrdered'] . "&price=" . number_format($product['priceIncl'], 2) * 100;
}

    $url= file_get_contents('http://api.softwear.nl/scripts/foxisapi.dll/sww1.wreq1.mpx?sendorder&token=' . $swToken . '
                        &custnum=' . $custNum . '&email=' . $email . '&title=' . $gender . '&firstname=' . $firstname . '&middlename=' . $middlename . '&lastname=' . $lastname . '
                        &street=' . $addressBillingName . '&housenum=' . $addressBillingNumber . '&zipcode=' . $addressBillingZipcode . '&city=' . $addressBillingCity . '
                        &countrycode=' . $code . '&shipping=' . $shipmentTrim . '&discount=' . $discountTrim . '&refid=' . $referralId . $producten++); 

echo $url;

如果我用 header(location) 来做,那很好,但我认为这不是解决这个问题的方法。

【问题讨论】:

  • 使用 curl 作为替代
  • 我认为$producten++ 在这里不正确

标签: php url post get


【解决方案1】:

我明白了。这是有相同问题的人的代码。

    /* cURL Resource */
$ch = curl_init();

/* Set URL */
curl_setopt($ch, CURLOPT_URL, 'http://api.softwear.nl/scripts/foxisapi.dll/sww1.wreq1.mpx?sendorder&token=' . $swToken . '
                        &custnum=' . $custNum . '&email=' . $email . '&title=' . $gender . '&firstname=' . $firstname . '&middlename=' . $middlename . '&lastname=' . $lastname . '
                        &street=' . $addressBillingName . '&housenum=' . $addressBillingNumber . '&zipcode=' . $addressBillingZipcode . '&city=' . $addressBillingCity . '
                        &countrycode=' . $code . '&shipping=' . $shipmentTrim . '&discount=' . $discountTrim . '&refid=' . $referralId . $producten++);

/* Tell cURL to return the output */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

/* Tell cURL NOT to return the headers */
curl_setopt($ch, CURLOPT_HEADER, false);

/* Execute cURL, Return Data */
$data = curl_exec($ch);

/* Check HTTP Code */
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

/* Close cURL Resource */
curl_close($ch);

/* 200 Response! */
if ($status == 200) {

    /* Debug */
    var_dump($data);

} else {

    /* Debug */
    var_dump($data);
    var_dump($status);

}

【讨论】:

    猜你喜欢
    • 2013-08-18
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-13
    • 2015-01-08
    • 2017-03-13
    • 1970-01-01
    相关资源
    最近更新 更多