Topic-icon Need help. Facebook permission problem - Undefined index

Active Subscriptions:

None
12 years 2 months ago - 12 years 2 months ago #42514 by ideaweb
Hello support. I am using your component to handle facebook logins, and facebook custom sharing. Everything is working except when sharing.

We suspect the error beeing that jfb is asking facebook if this content has already been shared, but jfb is not allowed to obtain this information and therefore SHARES the content, and returns with following error message:
Notice: Undefined index: message in /var/www/vhosts/MYSITE.COM/httpdocs/components/com_jfbconnect/libraries/provider/facebook.php on line 256

We suspect this code to be responsible:

$response = $this->api('/me/feed');
if (isset($response[0]))
$currentMessage = $response[0];



IF i remove these lines above from the code, everything is working. But that is not really the best solution.



And this is our code:
$post = array(
'name' => 'www.GolfRating.dk - '.$club->name,
'caption' => 'Rate:'.$lastRating->rate ,
'from' => $jfbcLibrary->getProviderUserId(),
'picture' => $this->getFacebookRateImage($lastRating->rate),
'link' => $currentLink,
'message' => 'Har netop rated: '.$club->name,
'description' => $lastRating->comment
);
Last edit: 12 years 2 months ago by ideaweb.
The topic has been locked.
Support Specialist
The code your using to post has been in JFBConnect a long time and will be revised in an upcoming release with our new Channels features. Channels were released in JFBConnect v6.0 and make it easier to post content to a Facebook Page or Group, Twitter Stream or LinkedIn Company. It doesn't directly work with Timelines yet, but will soon.

Until we make Channels work with user Timelines, the code you're using is correct. However, it seems like you're using an older version of JFBConnect still. The setFacebookMessage code in v6.0+ now looks like:
function setFacebookMessage($message)
    {
        if ($message)
        {
            try
            {
                $liveMessage = '';

                $response = $this->api('/me/feed');
                if (isset($response['data']) && isset($response['data'][0]) && isset($response['data'][0]['message']))
                    $liveMessage = $response['data'][0]['message'];

                $newMessage = is_array($message) && isset($message['message']) ? $message['message'] : $message;

                if ($liveMessage != $newMessage)
                {
                    if (is_array($message))
                        $response = $this->api('/me/feed', $message);
                    else
                        $response = $this->api('/me/feed', array('message' => $message));
                }
            }
            catch (JFBCFacebookApiException $e)
            {
            }
        }
    }
It's very similar to before, but there are more checks on the returned statuses from Facebook to prevent the PHP notice you were getting before (and some other minor differences).

Feel free to replace the setFacebookMessage code in the version of JFBConnect you're using.. or upgrade to JFBConnect 6.0.3 (the current latest).

I hope that gets you going, but if not, just let us know,
Alex
The topic has been locked.