I have tried to post the following data with PHP without HTML
<form class="paypal" action="payments.php" method="post" id="paypal_form">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="lc" value="DE" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
<input type="hidden" name="first_name" value="Customer's First Name" />
<input type="hidden" name="last_name" value="Customer's Last Name" />
<input type="hidden" name="payer_email" value="[email protected]" />
<input type="hidden" name="item_number" value="123456" / >
<input type="submit" name="submit" value="Submit Payment"/>
</form>
What I have tried is:
$response = httpPost("payments.php",
array(
'cmd' => '_xclick',
'no_note' => '1',
'lc' => 'DE',
'bn' => 'PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest',
'first_name' => 'Customers First Name',
'last_name' => 'Customers Last Name',
'payer_email' => '[email protected]',
'item_number' => '123456',
'submit' => 'Submit Payment')
);
function httpPost($url, $data){
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
... but this method not works - I only see a white page when I echo the response.
question from:
https://stackoverflow.com/questions/65875793/post-data-with-php-only 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…