WordPress.org

Ready to get started?Download WordPress

Forums

Facebook
[resolved] Cannot Redeclare class facebook (6 posts)

  1. quimbox
    Member
    Posted 1 year ago #

    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

    http://wordpress.org/extend/plugins/facebook/

  2. quimbox
    Member
    Posted 1 year ago #

    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_CONNECTTIMEOUT => 10,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 60,
    CURLOPT_USERAGENT => 'facebook-php-3.1',
    );`

    Now my app worked well.

    Sorry for my english my native language is spanish.

    Regards.

  3. Matt Kelly (Facebook)
    Member
    Plugin Contributor

    Posted 1 year ago #

    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.

  4. quimbox
    Member
    Posted 1 year ago #

    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

  5. Matt Kelly (Facebook)
    Member
    Plugin Contributor

    Posted 1 year ago #

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

  6. quimbox
    Member
    Posted 1 year ago #

    @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.

    Regards

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic