SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fatal error: Call to a member function fql_query() on a non-object in facebook php

    Hi there,

    I have a problem with my php script which im developing for my facebook application this is my php code

    PHP Code:
    $app_name = "GAME";
    $app_url = "http://apps.facebook.com/Game/"; // Assumes application is at http://apps.facebook.com/app-url/
    $invite_href = "invite.php"; // Rename this as needed
    if(isset($_POST["ids"])) {
        echo "<center>Thank you for inviting ".sizeof($_POST["ids"])." of your friends on <b><a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a></b>.<br><br>\n";
        echo "<h2><a href=\"http://apps.facebook.com/".$app_url."/\">Click here to return to ".$app_name."</a>.</h2></center>";
    } else {
        // Retrieve array of friends who've already authorized the app.
        $fql = 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='.$user.') AND is_app_user = 1';
        $_friends = $facebook->api_client->fql_query($fql);
        // Extract the user ID's returned in the FQL request into a new array.
        $friends = array();
        if (is_array($_friends) && count($_friends)) {
            foreach ($_friends as $friend) {
                $friends[] = $friend['uid'];
            }
        }

        // Convert the array of friends into a comma-delimeted string.
        $friends = implode(',', $friends);

        // Prepare the invitation text that all invited users will receive.
        $content =
            "<fb:name uid=\"".$user."\" firstnameonly=\"true\" shownetwork=\"false\"/> has started using <a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a> and thought it's so cool even you should try it out!\n".
            "<fb:req-choice url=\"".$facebook->get_add_url()."\" label=\"Put ".$app_name." on your profile\"/>";

    ?>
    <fb:request-form
        action="<? echo $invite_href?>"
        method="post"
        type="<? echo $app_name?>"
        content="<? echo htmlentities($content,ENT_COMPAT,'UTF-8'); ?>">

        <fb:multi-friend-selector
            actiontext="Here are your friends who don't have <? echo $app_name?> yet. Invite whoever you want -it's free!"
            exclude_ids="<? echo $friends?>" />
    </fb:request-form>
    <?PHP
    }
    The error i am actually getting is

    Fatal error: Call to a member function fql_query() on a non-object in /home/willbcco/public_html/facebook/invite.php on line 11

    On Line 11 i have this

    PHP Code:
    $_friends $facebook->api_client->fql_query($fql); 
    What is wrong with the above code how can i get rid of the fql query error?

    Thanks,William

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    You're missing a definition for $facebook

    It'll look something like this:

    Code php:
    $facebook = new Facebook($api_key, $secret);
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get this the result is this

    Notice: Undefined variable: user in /home/willbcco/public_html/facebook/invite.php on line 11

    Fatal error: Uncaught exception 'FacebookRestClientException' with message 'Parser error: unexpected ')' at position 70.' in /home/willbcco/public_html/facebook/php/facebookapi_php5_restlib.php:3112 Stack trace: #0 /home/willbcco/public_html/facebook/php/facebookapi_php5_restlib.php(1025): FacebookRestClient->call_method('facebook.fql.qu...', Array) #1 /home/willbcco/public_html/facebook/invite.php(12): FacebookRestClient->fql_query('SELECT uid FROM...') #2 {main} thrown in /home/willbcco/public_html/facebook/php/facebookapi_php5_restlib.php on line 3112

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    The Facebook Development Forum may well be better placed to resolve these issues for you.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay thanks ill post there thanks mate,


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •