دسته‌بندی نشده

Not being able to retrieve parameter from url in wp engine.


Replies: 0

I have this WordPress site where I use woocommerce for payments. Once a payment is done and the order is complete, a presigned url is generated from R2 bucket in cloudflare and it is appended to the URL of the page that streams the video:

<?php
/*
Template Name: Movie Player
*/

get_header();

$url = isset($_GET['url']) ? esc_url($_GET['url']) : '';

if ($url):

    echo '<pre>';
    print_r($url); // Print the final URL for debugging
    echo '</pre>';
?>  
    <video controls controlsList="nodownload">
        <source src="https://iranwebsazan.org/not-being-able-to-retrieve-parameter-from-url-in-wp-engine/<?php echo $url; ?>" type="video/mp4">
        Your browser does not support the video tag.
    </video>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const video = document.querySelector('video');
            video.addEventListener('contextmenu', function(e) {
                e.preventDefault(); // Disable right-click context menu
            });
             // Log the video URL to the console
             console.log("Video URL:", "https://iranwebsazan.org/not-being-able-to-retrieve-parameter-from-url-in-wp-engine/<?php echo $url; ?>");
        });
    </script>
<?php
else:
    echo 'No video URL provided.';
endif;

get_footer();

This is the function that generates the presigned url in functions.php.

function handle_order_complete($order_id) {
    $order = wc_get_order($order_id);

    if ($order->has_status('completed')) {
        // Retrieve the bucket name and object key from environment variables
        $bucketName="ngop-movie";
        $objectKey = 'kot-2-movie.mp4';

        // Generate the pre-signed URL
        $presignedUrl = generate_presigned_url($bucketName, $objectKey);

        // Redirect the user to the movie player page with the pre-signed URL
        wp_redirect('https://kotthemovie.com/movie-stream?url=" . urlencode($presignedUrl));
        exit;
    }
}

In my video player page I retrieve the parameter from the url and use it as source in my video player to stream the video. It works fine locally with localhost but on my deployed wordpress site in wp engine I am not able to retrieve the parameter and add it to the source of the video. The video player doesn’t show at all. Can anyone please help me resolve this issue?

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس



این خبر را در ارتباط فردا دنبال کنید.

لینک حبر

نوشته های مشابه

دکمه بازگشت به بالا