Home Ask Login Register

Developers Planet

Your answer is one click away!

forlove pakistan February 2016

how to i get only URL in json in PHP

How to i get data in JSON of Mention format i want to get data with this formate of json
Please guide me how can i do this.
Thanks in advance

i have already try this code

$url = 'http://api.miyulasi.com/youtube/1.0.0/download.php?id=7lCDEYXw3mM';
$data = file_get_contents($url);
header('Content-Type: application/json');
echo $data;

and now responde back is like this

<div class="col-md-3 col-sm-3 col-xs-6 text-center downbuttonbox"><a href="http://redirector.googlevideo.com/videoplayback?


Gwendal February 2016

Here you go


$url = 'http://api.miyulasi.com/youtube/1.0.0/download.php?id=7lCDEYXw3mM';
$data = file_get_contents($url);

$doc = new DOMDocument();
$xpath = new DomXPath($doc);

$links = array();
$expression = "//a[contains(@class, 'btn btn-default btn-sm downbuttonstyle')]";
foreach($xpath->evaluate($expression) as $link) {
    $content = $link->textContent;
    $link = $link->getAttribute('href');
    preg_match("/&mime=([^&]*)&/", $link, $mime);
    preg_match("/&itag=([^&]*)&/", $link, $itag);
    preg_match("/\((.*)\)/", $content, $quality);

    $links[] = array("itag" => $itag[1], "type" => $mime[1], "url" => $link, "quality" => $quality[1]);
header('Content-Type: application/json');
echo json_encode($links, JSON_PRETTY_PRINT);

Post Status

Asked in February 2016
Viewed 1,040 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life