WordPress.org

Ready to get started?Download WordPress

Forums

WP-o-Matic
Setting SimplePie user agent (3 posts)

  1. Erik
    Member
    Posted 1 year ago #

    I am trying to set the user agent string for SimplePie.

    I have tried to change the constant in the wp-o-matic/inc/simplepie/simplepie.class.php file by replacing the original define of SIMPLEPIE_USERAGENT.

    However, when I check the HTTP-request from WP-o-Matic it still uses the "old" user agent string.

    I've also tried to set this value using phprc, with the same result.

    What is the recommended way for setting the user agent string when using SimplePie with WP-o-Matic?

    I looked in the code for SimplePie and noticed the constructor of the SimplePie class accepts a user agent parameter, and that neither SIMPLEPIE_USERAGENT nor user agent from phprc is used if that value is set.

    Do you set the user agent in the creation of the SimplePie class?

    Kind Regards,

    /Erik

    http://wordpress.org/extend/plugins/wp-o-matic/

  2. Erik
    Member
    Posted 1 year ago #

    I looked in the code for SimplePie and noticed the constructor of the SimplePie class

    Sorry about this, it wasn't the SimplePie class but the SimplePie_File class...

  3. Erik
    Member
    Posted 1 year ago #

    The problems I've had did not depend on how to set the user agent (at least not only).

    However this can be done (for SimplePie) setting the user_agent variable in php.ini, phprc or .htaccess.

    The problem with WP-o-Matic's implementation (or if it's SimplePie's) is that you seem to have to create the SimplePie-class with the URL as an argument in order for the system to pick up the changed user_agent string setting.

    As things stand now, you cannot change the user_agent setting and make WP-o-Matic use it.

    I solved this by adding a manual user agent string in the part of wp-o-matic/wpomatic.php that creates the SimplePie class.

    I did this by adding the following statement after the $feed variable had been created. I also allowed for the URL to be set to be on the safe side (meaning I added the line after the $feed->set_feed_url($url);).

    This is the line I added:

    $feed->set_useragent('Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1');

    Some RSS freeds will still fail (due to a bug that makes WP-o-Matic handle ampersands & incorrectly)... - see my post about that...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic