php-general Digest 9 Feb 2012 15:55:51 -0000 Issue 7682

Topics (messages 316565 through 316568):

Re: Help! Having trouble getting one XML field from this feed reliably
        316565 by: Adam Richardson
        316566 by: Yared Hufkens
        316568 by: Adam Richardson

PHP-GTK: GladeXML::get_widget() doesn't find some widgets
        316567 by: Yared Hufkens

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Wed, Feb 8, 2012 at 10:44 PM, Rob Gould <gould...@mac.com> wrote:

> Can anyone tell me what I'm doing wrong here?  I'm trying to get the
> VASTAdTagURI field from the XML data at this url:
>
> http://afe.specificclick.net/?l=32259&t=x&rnd=123456
>
>
>
>
> Here's my code.  (below).  It works maybe 30% of the time, but most of the
> time it just returns nothing from that field.  Yet when I go to the above
> url in Firefox, I always see the data.  This is very strange.
>
>
>
>
>
> // Lets get the ad!
>
> $curl_handle=curl_init();
> curl_setopt($curl_handle,CURLOPT_URL,'
> http://afe.specificclick.net/?l=32259&t=x&rnd=123456');
> curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
> curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
> $buffer = curl_exec($curl_handle);
> curl_close($curl_handle);
>
> $vastdata = new SimpleXMLElement($buffer);
>
> $vasturi = $vastdata->Ad->Wrapper->VASTAdTagURI;
>
> echo "If the script works, vasturi = " . $vasturi;
>
> echo "<br><br><br>";
>
> print_r($vastdata);
>

I'd try adding some error checks to see what issues curl may be having:

$str = curl_exec($ch);
$error_no = curl_errno($ch);
curl_close ($ch);

if ($error_no != 0)
    throw new Exception('There was an error retrieving the string contents
of the url \''.$url.'\'. CURL error number:'.$error_no);

I wonder if you transaction is timing out, which you can set as below:

curl_setopt($ch, CURLOPT_TIMEOUT, $transaction_timeout = 2);

Adam


-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
I wonder why you use cURL as SimpleXML itself can load URLs:

$vastdata = new
SimpleXMLElement('http://afe.specificclick.net/?l=32259&t=x&rnd=123456',0,true);

See http://de.php.net/manual/en/simplexmlelement.construct.php


Am 09.02.2012 04:44, schrieb Rob Gould:
> Can anyone tell me what I'm doing wrong here?  I'm trying to get the 
> VASTAdTagURI field from the XML data at this url:
>
> http://afe.specificclick.net/?l=32259&t=x&rnd=123456
>
>
>
>
> Here's my code.  (below).  It works maybe 30% of the time, but most of the 
> time it just returns nothing from that field.  Yet when I go to the above url 
> in Firefox, I always see the data.  This is very strange.
>
>
>
>
>
> // Lets get the ad!
>
> $curl_handle=curl_init();
> curl_setopt($curl_handle,CURLOPT_URL,'http://afe.specificclick.net/?l=32259&t=x&rnd=123456');
> curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
> curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
> $buffer = curl_exec($curl_handle);
> curl_close($curl_handle);
>
> $vastdata = new SimpleXMLElement($buffer);
>
> $vasturi = $vastdata->Ad->Wrapper->VASTAdTagURI;
>
> echo "If the script works, vasturi = " . $vasturi;
>
> echo "<br><br><br>";
>
> print_r($vastdata);
>
>
>
>
>
>
>

--- End Message ---
--- Begin Message ---
On Thu, Feb 9, 2012 at 9:10 AM, Yared Hufkens <y4...@yahoo.de> wrote:

> I wonder why you use cURL as SimpleXML itself can load URLs:
>
> $vastdata = new
> SimpleXMLElement('http://afe.specificclick.net/?l=32259&t=x&rnd=123456
> ',0,true);
>
> See http://de.php.net/manual/en/simplexmlelement.construct.php


It is pretty convenient that SimpleXMLElement allows you to grab URL's, but
curl allows me to manually set a timeout limit (along with many other
things, although they're not necessarily needed in Rob's example), so I
tend to use curl in this type situation, too.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
I have a Glade file with this widget:

        <child>
          <widget class="GtkTextView" id="errLog">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="editable">False</property>
            <property name="cursor_visible">False</property>
            <property name="accepts_tab">False</property>
          </widget>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>

which is a child of a GtkVBox (errContainer), which is a child of a
GtkWindow (errWindow), and I want to write something into it:

function openErr($message) {
        logError($message);

        $window = glade()->get_widget('errWindow');
        $log = glade()->get_widget('errLog');

        $buf = new GtkTextBuffer();
        $buf->set_text(file_get_contents(LOG_FILE) or "Cannot read file 
".LOG_FILE."!");

        $log->set_buffer($buf);
        $log->modify_font(new PangoFontDescription('Monospace'));

        $window->show_all();
}


But get_widget() doesn't find errLog: I get a Fatal Error and
var_dump($log) outputs null. errWindow gets found anyway, and if I
comment the two lines with $log->method() out, errWindow appears on the
screen too.

How can I get the object of errLog?

--- End Message ---

Reply via email to