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

2012-02-09 Thread php-general-digest-help

php-general Digest 9 Feb 2012 15:55:51 - 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


--
---BeginMessage---
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=32259t=xrnd=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=32259t=xrnd=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 brbrbr;

 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---
---BeginMessage---
I wonder why you use cURL as SimpleXML itself can load URLs:

$vastdata = new
SimpleXMLElement('http://afe.specificclick.net/?l=32259t=xrnd=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=32259t=xrnd=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=32259t=xrnd=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 brbrbr;

 print_r($vastdata);







---End Message---
---BeginMessage---
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=32259t=xrnd=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---
---BeginMessage---
I have a Glade file with this widget:

child
  widget class=GtkTextView id=errLog
property name=visibleTrue/property
property name=can_focusTrue/property
property name=editableFalse/property
property name=cursor_visibleFalse/property
property name=accepts_tabFalse/property
  /widget
  packing
property name=expandTrue/property
property name=fillTrue/property
property name=position2/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 = 

Re: [PHP] Help! Having trouble getting one XML field from this feed reliably

2012-02-09 Thread Yared Hufkens
I wonder why you use cURL as SimpleXML itself can load URLs:

$vastdata = new
SimpleXMLElement('http://afe.specificclick.net/?l=32259t=xrnd=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=32259t=xrnd=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=32259t=xrnd=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 brbrbr;

 print_r($vastdata);








-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP-GTK: GladeXML::get_widget() doesn't find some widgets

2012-02-09 Thread Yared Hufkens
I have a Glade file with this widget:

child
  widget class=GtkTextView id=errLog
property name=visibleTrue/property
property name=can_focusTrue/property
property name=editableFalse/property
property name=cursor_visibleFalse/property
property name=accepts_tabFalse/property
  /widget
  packing
property name=expandTrue/property
property name=fillTrue/property
property name=position2/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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help! Having trouble getting one XML field from this feed reliably

2012-02-09 Thread Adam Richardson
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=32259t=xrnd=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