Skip to Content

PHP Code Examples

This page provides complete examples for calling the MeowLoad API with PHP.

๐Ÿš€ Using file_get_contents

<?php $apiUrl = "https://api.meowload.net/openapi/extract/post"; $apiKey = "your-api-key-here"; $params = array("url" => "https://www.youtube.com/watch?v=dQw4w9WgXcQ"); $options = array( "http" => array( "header" => "Content-Type: application/json\r\n" . "x-api-key: " . $apiKey . "\r\n" . "accept-language: zh", "method" => "POST", "content" => json_encode($params), ), "ssl" => array( "verify_peer" => false, "verify_peer_name" => false, ), ); $context = stream_context_create($options); $response = file_get_contents($apiUrl, false, $context); // Parse HTTP response status code $statusLine = $http_response_header[0]; preg_match('{HTTP\/\S*\s(\d{3})}', $statusLine, $match); $statusCode = $match[1]; $data = json_decode($response, true); if ($statusCode == 200) { echo "โœ… Extraction successful!\n"; echo "Media count: " . count($data['medias']) . "\n"; foreach ($data['medias'] as $media) { echo "- " . $media['media_type'] . ": " . $media['resource_url'] . "\n"; } } else { echo "โŒ Request failed (" . $statusCode . "): " . $data['message'] . "\n"; } ?>

๐Ÿ“ฆ Using cURL

<?php function extractPost($url, $apiKey) { $apiUrl = "https://api.meowload.net/openapi/extract/post"; $ch = curl_init($apiUrl); $payload = json_encode(array("url" => $url)); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'x-api-key: ' . $apiKey, 'accept-language: zh' )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $data = json_decode($response, true); if ($statusCode == 200) { return $data; } else { throw new Exception($data['message']); } } // Usage try { $result = extractPost("https://www.youtube.com/watch?v=dQw4w9WgXcQ", "your-api-key-here"); echo "โœ… Extraction successful! Media count: " . count($result['medias']) . "\n"; } catch (Exception $e) { echo "โŒ Error: " . $e->getMessage() . "\n"; } ?>