Support » Plugin: Facebook » Cannot Redeclare class facebook

  • Resolved quimbox


    I have an application that works with the template I have on my website, but when I activate the plugin facebook. And when trying to upload a photo from my site to facebook, I get this error.

    Fatal error: Cannot redeclare class Facebook

    It may be because, for in the application that use the files I have already facebook.php like the facebook plugin folder.

    Is there any solution for this?

    Remarkably, when I disable the plugin, my application works perfect

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi all, I could solve the problem I had.

    I added the condition if, in my files facebook.php and base_facebook.php

    if ( ! class_exists( 'FacebookApiException' ) ): this condition i added into my file base_facebook.php

    And this if ( ! class_exists( 'Facebook' ) ): into my file facebook.php

    But when I tried to upload the image from my website to facebook, got an error which was not declaring the function $CURL_OPTS in class BaseFacebook in the file base_facebook.php of the plugin facebook.

    So I had to add the default option for curl, in the base_facebook.php of the plugin facebook.

    `public static $CURL_OPTS = array(
    CURLOPT_USERAGENT => ‘facebook-php-3.1’,

    Now my app worked well.

    Sorry for my english my native language is spanish.


    Plugin Contributor Matt Kelly (Facebook)


    What line? Can you paste the full error?

    We don’t use the class Facebook. We use WP_Facebook, so this should be a non-issue.

    Hi @matt Kelly I’ve solved the problem. Adding conditions to my files. But there was a function not declared in the file base_facebook.php of the plugin facebook. The function $CURL_OPTS I had to add it to the file. For my application worked

    Plugin Contributor Matt Kelly (Facebook)


    @quimbox, awesome glad you got it fixed. Is the code available anywhere?

    @matt Kelly I guess that refers to the plugin file base_facebook.php

    The recent php facebook sdk is available on github . But the archive base_facebook.php in the folder facebook-php-sdk of the plugin not contain the default options for curl, maybe you want to update it.


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Cannot Redeclare class facebook’ is closed to new replies.