sevastian25 Posted January 29, 2017 Share Posted January 29, 2017 (edited) So i have this API and i got a new file in my directory for it called "mylittleapi.php" <?php $curl = curl_init(); $coupon_code = '****-6dcf-****-4d05-bd68-****-****-****'; $data = json_encode(array( 'coupon_code' => $coupon_code, 'receiver_id64' => '76561************' )); curl_setopt_array($curl, array( CURLOPT_URL => "https://theirwebsite.com/api/v1/money/coupon/redeem", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => array( "authorization: Basic *******************************************************************=", "cache-control: no-cache", "content-type: application/json", "postman-token: ********-****-****-****-************" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } when i access it through www.mywebsite.com/mylittleapi.php it does execute but what i want to do is set the coupon_code as a variable which users can just enter their own coupons and set the Textbox and submit button in another page ex: "www.mywebsite.com/redeem" I just need to make the variable for the coupon_code, link it to my textbox and button in the other page. Can somebody help me out please ? i really need this to be done. Edited January 29, 2017 by sevastian25 Quote Link to comment https://forums.phpfreaks.com/topic/303054-api-little-problem/ Share on other sites More sharing options...
NotionCommotion Posted January 30, 2017 Share Posted January 30, 2017 Needs a little work, but the following should get you going in the right direction. CLIENT SIDE: <a href="?coupon_code=****-6dcf-****-4d05-bd68-****-****-****>click me</a> SERVER SIDE: $coupon_code=$_GET['coupon_code']; Quote Link to comment https://forums.phpfreaks.com/topic/303054-api-little-problem/#findComment-1542103 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.