Semnomic Posted May 8, 2017 Share Posted May 8, 2017 <form action="form.php" method="get"> <label>Redbubble Design url: <input style height="20" width="40" type="numeric" name="url" size="35" /> </label> <p></p> <label>Design Short Desc: <input style height="20" width="40" type="numeric" name="desc" size="35"/> </label> <p></p> <label>Product Hashtags: <input style height="20" width="40" type="numeric" name="tags" size="35"/> </label> <p></p> <input type="submit"> </form> <p></p> <?php parse_str($_SERVER['QUERY_STRING']); echo $url;?> <?php $page_content = file_get_contents('$url'); $dom_obj = new DOMDocument(); $dom_obj->loadHTML($page_content); $meta_val = null; foreach($dom_obj->getElementsByTagName('meta') as $meta) { if($meta->getAttribute('property')=='og:image'){ $meta_val = $meta->getAttribute('content'); } } echo $meta_val; ?> First time posting here so i hope i got it right. im making a small program that parses OG image from a url. The above code works if I replace $url in the main php section of code with the actual url > https://www.redbubble.com/people/podartist/works/22431751-neon-orange-puffy-stitch-quilt Can anyone see what im doing wrong when i try and use the stored string $url ? $url is exactly the same as the url so im lost. Hope that makes sense. Thanks in advance Quote Link to comment Share on other sites More sharing options...
dkub Posted May 8, 2017 Share Posted May 8, 2017 Why do you have quotes around $url in your file_get_contents call? Any quotes are unnecessary here, and single quotes prevent string interpolation, meaning you're passing the literal string "$url" as your parameter. Quote Link to comment Share on other sites More sharing options...
Semnomic Posted May 9, 2017 Author Share Posted May 9, 2017 I know thats where the problem is i tried '' and "" so i dont know why its not working, I can echo it so i know its there/stored but i can use it in the second part of code. What im trying to do is get that OG image to appear on my form. How would you make a small form that grabs an OG image from that url i gave and echos it out after you submit? If i can get it to echo i will be ok with the image part. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.