Viewing file: q.php (1.29 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
// WordPress API URL
define('WP_API_URL', 'https://turkifsa.co/wp-json/wp/v2/posts');
// cURL ile veri çekme fonksiyonu
function sendCurlRequest($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
// HTML içindeki ouo.io linklerini ayıklama
function extractOuoLinks($html) {
$ouo_links = [];
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($html);
libxml_clear_errors();
foreach ($dom->getElementsByTagName('a') as $a) {
$href = $a->getAttribute('href');
if (strpos($href, 'ouo.io') !== false) {
$ouo_links[] = $href;
}
}
return $ouo_links;
}
// WordPress yazılarını çek
function fetchPosts() {
$response = sendCurlRequest(WP_API_URL);
return json_decode($response, true);
}
// Ana işlem
$posts = fetchPosts();
$result = [];
foreach ($posts as $post) {
$title = $post['title']['rendered'];
$content = $post['content']['rendered'];
$ouo_links = extractOuoLinks($content);
if (!empty($ouo_links)) {
$result[] = [
'title' => $title,
'ouo_links' => $ouo_links
];
}
}
// JSON olarak çıktı ver
header('Content-Type: application/json');
echo json_encode($result, JSON_PRETTY_PRINT);
?>
|