Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to grab a field name's value in a CURL response
    primarykey
    data
    text
    <p>I first want to say I'm a beginner with PHP and my code is definitely not efficient to say the least. </p> <p>The issue I'm having currently is I want to parse the CURL response in a manner to grab several field name values and assign them to a variable. Once I have the variables I'll display some fields back to the customer and some to a database. I know what fields will be sent back as I'm working with PayPal's APIs however I am unsure on how to "grab" them from the response.</p> <p>Here is my script I'm currently using, again not very efficient however I'm stuck after the CURL request. Any help is greatly appreciated!!</p> <pre><code>&lt;?php include_once "constants.php"; foreach ($_POST as $key =&gt; $value) { $value = urlencode(stripslashes($value)); $wppro = "$key=$value"; } $ipaddress = "216.113.168.139"; $creditcardtype = $_POST["creditcardtype"]; $acct = $_POST["acct"]; $expmo = $_POST["expmo"]; $expyear = $_POST["expyear"]; $cvv = $_POST["cvv"]; $firstname = $_POST["firstname"]; $lastname = $_POST["lastname"]; $street = $_POST["street"]; $street2 = $_POST["street2"]; $city = $_POST["city"]; $state = $_POST["state"]; $zip = $_POST["zip"]; $countrycode = $_POST["countrycode"]; $amt = $_POST["amt"]; $expdate = $expmo . $expyear; $method = "DoDirectPayment"; $nvp = "version=$version&amp;method=$method&amp;user=$api_user&amp;pwd=$api_pwd&amp;signature=$api_sig&amp;ipaddress=$ipaddress&amp;$creditcardtype=$creditcardtype&amp;acct=$acct&amp;expdate=$expdate&amp;cvv=$cvv&amp;firstname=$firstname&amp;lastname=$lastname&amp;street=$street&amp;street2=$street2&amp;city=$city&amp;state=$state&amp;zip=$zip&amp;countrycode=$countrycode&amp;amt=$amt"; $ch = curl_init(); // Starts the curl handler curl_setopt($ch, CURLOPT_URL,$sburl); // Sets the paypal address for curl curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Returns result to a variable instead of echoing curl_setopt($ch, CURLOPT_TIMEOUT, 60); // Sets a time limit for curl in seconds (do not set too low) curl_setopt($ch, CURLOPT_POST, 1); // Set curl to send data using post curl_setopt($ch, CURLOPT_POSTFIELDS, $nvp); // Add the request parameters to the post $httpResponse = curl_exec($ch); // run the curl process (and return the result to $result curl_close($ch); </code></pre> <p>Thank you,</p> <p>Matt</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload