views:

48

answers:

2

I am using the Thumbalizr API for capturing website screenshots.

I am trying to pass a url from a variable into the script below where it currently says "www.google.com".

When I try and do $url = "www.google.com"; and pass that to $image->request($url); it seems to fail and retrieves a screenshot but one that suggests the url was unreachable.

Any what am I doing wrong?

Here is the original php in full working order.

<?php

    define ("_THUMBALIZR",1);

    require_once("config.inc.php"); // get config and functions
    $image=new thumbalizrRequest(); // create object
    $image->request("www.google.com"); // send request

    if ($image->headers['Status']=="OK" || $image->headers['Status']=="LOCAL") { // if picture is available
     $image->output(); //dump binary image data
    } else {
     print_r($image->headers); // print text result output - you can dump your own "queued" picture here
    }

    ?>
A: 

If you show us your current code, IE the one with $url, that may help. In short, $url being used in place of "www.google.com" should not make a difference, as long as $url is being defined correctly and in the current scope (if inside of a function).

Show the current and we can better help you solve this issue.

Brad F Jacobs
This is the code I've been trying to use.<?php $url = "www.google.com"; define ("_THUMBALIZR",1); require_once("config.inc.php"); // get config and functions $image=new thumbalizrRequest(); // create object $image->request($url); // send request if ($image->headers['Status']=="OK" || $image->headers['Status']=="LOCAL") { // if picture is available $image->output(); //dump binary image data } else { print_r($image->headers); // print text result output - you can dump your own "queued" picture here } ?>
Craig
Put the $url after the config.inc.php, I bet there is a variable being set in there that is "$url" as well and is overwriting your variable.
Brad F Jacobs
Ahh... there is another variable called $url.I will test that when I get a chance.
Craig
That was indeed the problem. Thanks
Craig
A: 

It needs to be http://www.google.com :)

Ahmed Nuaman