<?php

$curl = curl_init();

// Get the current post ID.
$post_id = get_the_ID();

// Get the 'video_refresh_url' ACF field value for the current post.
$video_refresh_url = get_field("chau_video_refresh_url", $post_id);

// Use the variable $video_refresh_url for the cURL request.
curl_setopt_array($curl, [
  CURLOPT_URL => $video_refresh_url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer E9YdEy6ZAjvigAwY8jCxCJdE2zTp0AO8lv5Jk8sP",
    "User-Agent: insomnia/8.4.5"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  
  //process response to shorten url
  
  $responseData = json_decode($response, true);

// Extract the long URL
$longUrl = $responseData['value'][0]['file'];
  
  echo $longUrl;
  
  $yourls_api_url = 'https://links.omnichannelplus.com/yourls-api.php';
  
  $token = '63a72d7acd';
  
  // Prepare data for API request
$data = array(
    'signature' => $token,
    'action' => 'shorturl',
    'url' => $longUrl,
    'format' => 'json'
);
  
  // Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $yourls_api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

// Execute the request
$response = curl_exec($ch);
curl_close($ch);

// Decode the response
$shortUrlResponse = json_decode($response, true);

if (isset($shortUrlResponse['shorturl'])) {
    // Short URL
    echo 'Short URL: ' . $shortUrlResponse['shorturl'];
} else {
    // Handle error
    echo 'Error: ' . $shortUrlResponse['message'];
}
  
} ?>

CHAU Home Improvement

Hi, Greg! You requested an appointment

Appointment Date & TimeNovember 28, 2024 02:00pm
Preferred Contact Method[email protected] | +17274304341
Your Address4721 N Kimball Ave , Chicago, Illinois 60625

Your notes about the project

ComplaintNeed replacement

Our recommendation

Recommendation

After...

Would you prefer to call us now?