Home Profile Projects Articles

Facebook Application: ‘Invite Friends Page’ code

Monday, 16 of July , 2007 at 8:51 pm

While doing contracting work for Trend Hunter, I wrote code for an ‘Invite Friends Page’. Since this is common to almost every facebook application, I decided to publish my code. You can check it out here. Please note that I “borrowed” some of the css and javascript from the X-Me application. I didn’t really want to waste my time writing the page from scratch.

Category: Programming

7 Comments

Comment by Yannis

Made Saturday, 8 of December , 2007 at 9:42 am

I must be missing something

it gives me this error

PHP Fatal error: Call to undefined function intify() in /home/httpd/www/www.xxxxxxxxxxxx.com/facebook_m/invite.php on line 22, referer: http://apps.facebook.com/xxxxxxxxx/invite.php?friend_ids=xxxxxxxxx

Comment by eldila

Made Saturday, 8 of December , 2007 at 12:21 pm

Intify is a function that I created myself. I didn’t notice I still had that in my code example.

This is the missing function:

function intify($value)
{
if (is_numeric($value))
return round($value);
else
return 0;
}

Comment by Yannis

Made Saturday, 8 of December , 2007 at 11:09 pm

Thanks for the response
Now I have a new problem

i placed it right above the if($_REQUEST['friend_ids'])
and i get this

PHP Fatal error: Call to undefined method FacebookRestClient::notifications_sendRequest() in /home/httpd/www/www.xxxx.com/facebook_m/invite.php on line 31, referer: http://apps.facebook.com/xxxxx/invite.php?friend_ids=xxxxx

Comment by eldila

Made Saturday, 8 of December , 2007 at 11:46 pm

Hi Yannis,

I just downloaded the newest version of the facebook api.

The following function:
notifications_sendRequest($to_ids, $type, $content, $image, $invite)

has been replaced with:
notifications_send($to_ids, $notification)

You might have to do some more tinkering to get everything working with the new facebook api. I hope you find this information useful.

Comment by Yannis

Made Sunday, 9 of December , 2007 at 12:52 am

Hi eldila

thanks for the help

apache gives me no errors now but still i can not send the invitations

It returns me to the invite page but now it has in the address this

http://xxxxxxxxx/invite.php?friend_ids=xxxxxxxx

Comment by eldila

Made Sunday, 9 of December , 2007 at 12:04 pm

I would suggest debugging the code like any other program.

The problem could be that you tried sending to many invitations. It doesn’t look like my code example contains error messages when notifications_send fails.

Comment by Yannis

Made Monday, 10 of December , 2007 at 12:23 am

Hi eldila
Thank you very much
Just to inform you that the form was inviting people but it didn’t inform ME of this…

So again thanks very much for the help.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> [tex]