0

Any reason why i'm getting this error

PHP Notice:  Undefined index: url on line 40

From my code the code is used to grab link for movies from a site but as i try to grab the link i get that error so could someone point me in the right direction on solving the issue.

public function getMovieEmbeds($title) {
    $misc = new Misc(); 
    //Step1 find key
    $movie_url = null;
    $html = file_get_html('http://www.primewire.ag/');
    $elements = $html->find('input[name=key]',0);
    $key = null;
    if(!is_null($elements)){
        $key = $elements->value;
    }
    if(is_null($key)){
        return array();
    }

    //Step2 do search...
    $search = urlencode($title);                
    $html = file_get_html("http://www.primewire.ag/index.php?search_keywords=$search&key=$key&search_section=1");
    $elements = $html->find(".index_item h2");
    if(!is_null($elements)){
        foreach($elements as $element){
            $element_title = strtolower(strip_tags(trim(preg_replace('/\s*\([^)]*\)/', '', $element->innertext))));                 
            if ($element_title == strtolower(trim($title))) {
                $parent = $element->parent();
                $movie_url = "http://primewire.ag".$parent->href;
                break;
            }
        } 
    }
    if (is_null($movie_url)) { 
        return array();
    }

    //Step3 get embeds
    $html = file_get_html($movie_url);
    $elements = $html->find(".movie_version_link a");
    if(!is_null($elements)){
        foreach($elements as $element){
            $encoded_url = "http://primewire.ag".$element->href;
            $query = parse_url($encoded_url, PHP_URL_QUERY);
            parse_str($query,$op);
            error came from ---> $link = base64_decode($op["url"]); <--- here

            if(strpos($link, "affbuzzads")===false && strpos($link, "webtrackerplus")===false){
                $embed = $misc->buildEmbed($link);
                if ($embed) {
                    $embeds[] = array(
                        "embed" => $embed,
                        "link" => $link,
                        "language" => "ENG",
                    );
                }
            }
        }
        return $embeds;
    }
    return array(); 
}

could some one please help me it would be most helpful

2
  • 1
    du have done a var_dump($op) and looked if there is an index namend url? Commented Nov 15, 2013 at 12:55
  • if you are not aware those sites have been blocked in UK Commented Dec 3, 2013 at 17:31

1 Answer 1

2

parse_str returns an array of the parameters on a URL, as if it was in the $_GET array.

It would only contain a 'url' value if the url you used had a parameter 'url'

E.g. it was along the lines of:

http://example.com/?url=urlvalue

Therefore, if $element->href (and therefore $encoded_url and $query) does not contain a parameter named 'url' in it you'll not get an index in the $op array of 'url'

See the documentation here: https://www.php.net/manual/en/function.parse-str.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.