API tutorial for Curl/php

Note: Monthly limits can be seen in your account under the Account -> Account status & API
curl -X GET "https://xne.us/api" \
     -d "user_id=USER_ID" \
     -d "api_key=API_KEY" \
     -d "long_url=LONG_URL"
    


<?php

 // Insert data here
 $long_url = "YOUR LONG URL";
 $user_id = "YOUR USER ID";
 $api_key = "YOUR API KEY";

 $curl = curl_init();
 curl_setopt_array($curl, [
    CURLOPT_URL => "https://xne.us/api?user_id=$user_id&api_key=$api_key&long_url=$long_url",
    CURLOPT_RETURNTRANSFER => true,
 ]);
 $response = curl_exec($curl);
 curl_close($curl);

 $response_data = json_decode($response, true); 

 if ($response_data['code'] === 200) {
    echo "Shortened URL: " . $response_data['link'];
 } else {
    echo "Error: " . $response_data['code'];
 }

?>
    


Expected response
Array ( [code] => 200 [message] => Success [link] => https://xne.us/link )