Jump to content

facebook application to post on wall


alapimba

Recommended Posts

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/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.