alapimba Posted January 14, 2011 Share Posted January 14, 2011 Hello I'm trying to make a basic application on facebook and i have been the last 3 days trying to figure out how to do. I have searched all over the place but can't figure on how to do this. Any help would be very apreciated. What i want to do is just a simple application to post on the person that login a message on the wall. i've download the file facebook.php from here: https://github.com/facebook/php-sdk/ Then i have my index.php page with this code: <style type="text/css"> textarea { width: 99%; height: 100px; } legend { background-color: #3B5998; padding: 5px; color: #ffffff; font-size: 12px; font-weight: bold; } </style> <?php // Helper functions and static variables define('FB_ROOT', "http://apps.facebook.com/endbox_fotos/"); define('HTML_ROOT', "http://endbox.com/clientes/facebook_app/"); define('APP_ID', "xxxxxxx"); define('APP_SECRET', "xxxxxxxxx"); //thisisnotmysecret function fb_root($url="") { return FB_ROOT . $url; } function html_root($url="") { return HTML_ROOT . $url; } function redirectToCanvas() { header('Location: '.fb_root()); } ?> <script type="text/javascript" src="<?=html_root()?>scripts.js?v=0.2"></script> <?php require 'facebook.php'; $facebook = new Facebook(array( 'appId' => APP_ID, 'secret' => APP_SECRET, 'cookie' => true )); $debug = false; if ($facebook->getSession() && $debug == false) { // User is logged in and authorized, let's party. // Get friends list of current user $call = $facebook->api('/me/friends'); //$friends_list = $call['data']; $friends_list = array_slice($call[data], 0, 10); // Get user information of current user $call = $facebook->api('/me'); $my_info = $call; $user = $facebook->getUser(); ?> <fieldset> <legend>Stream Publish Example</legend> <a href="#" onclick="stream_publish_test()">DEMO</a> </fieldset><br/> <fieldset> <legend>Friends List Example</legend> <?php foreach($friends_list as $friend): ?> <fb:profile-pic uid="<?=$friend['id']?>" size="square"/> <?php endforeach; ?> </fieldset><br/> <?php } else { /** * --- * At this point we have determined that the user is not logged * in to the application. From here we'll need to authorize them * using the getLoginUrl() function available from the API library. * --- * * getLoginUrl parameters: * - next: the url to go to after a successful login * - cancel_url: the url to go to after the user cancels * - req_perms: comma separated list of requested extended perms * - display: can be "page" (default, full page) or "popup" **/ $params = array( 'fbconnect'=>0, 'canvas'=>1, 'req_perms'=>'', 'next'=>fb_root(), 'cancel_url'=>fb_root() ); $redirect = $facebook->getLoginUrl($params); echo '<fb:redirect url="' . $redirect . '">'; } ?> <fb:comments xid="graphapi_comments" canpost="true" candelete="false" returnurl="<?=fb_root()?>"> <fb:title>Talk about this demo</fb:title> </fb:comments> The file scripts.js has this: function fb_root() { return "http://apps.facebook.com/endbox_fotos/"; } function html_root() { return "http://endbox.com/clientes/facebook_app/"; } function stream_publish_test() { var message = ''; var attachment = { 'name': 'Graph api made by alapimba!', 'href': fb_root(), 'caption': '{*actor*} is playing with the new Graph API that alapimba is tring to do!', 'description': 'The Graph API enables you to read and write objects and connections in the Facebook social graph.', 'media': [{ 'type': 'image', 'src': 'http://endbox.com/core/logo_mm_pr.gif', 'href': fb_root()}] }; var action_links = [{'text':'Check It Out!', 'href':fb_root()}]; Facebook.streamPublish(message, attachment, action_links); } if you add this to your apps it will show you 10 friends, and a link called demo that opens a window that you can write text and that text appears on your wall... How this funcion happends? I mean.. i have the file scripts.js but has you can see the message on the function is not the same that appear on the popup. where that message came from?? If i change the file scripts.js name it stop working... what makes no sense because if the funcione came from that file the message should be mine.. no? ANyone can help? Thanks the url is for the app running is http://apps.facebook.com/endbox_fotos/ Quote Link to comment Share on other sites More sharing options...
phpfreak Posted January 15, 2011 Share Posted January 15, 2011 I have edited this to remove your API and Secret keys - you should not post these publicly as someone could use those to cause havoc on your facebook app... Quote Link to comment Share on other sites More sharing options...
alapimba Posted January 17, 2011 Author Share Posted January 17, 2011 there is no problem. i modify the secret so it wasn't mine. Quote Link to comment Share on other sites More sharing options...
khr2003 Posted January 18, 2011 Share Posted January 18, 2011 I would recommend that you use php alternative to js which is quite the same and I do not see why you use js. Also, it is better to use iframe rather than fbml since the latter will be deprecated in couple of months. Quote Link to comment Share on other sites More sharing options...
alapimba Posted January 18, 2011 Author Share Posted January 18, 2011 my problem is that i can't understand how to do it in any way. neither js neither php. can you help with examples? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.