5 Steps to publish on a facebook wall using php
Since Facebook has stopped supporting Java we need to use PHP for now to post on a wall.
According to facebook Wiki posting on a wall is very confusing and very difficult to write a program to publish on a wall.
I spent around 2 weeks reading many articles and many documents, Wiki on facebook but in vein and tried many ways and finally I got one workable model. Below are 5 simple steps to publish on a Facebook wall.
Step1: Login to Facebook to Create a Facebook App
First login to Facebook and goto the url http://www.facebook.com/developers/ then
Click on “+ Set Up New Application” button to start creating the application as shown below.
Provide the application name, click agree for facebook terms and click on “Create Application” button.
Fill in application Name
Now Application is created for you. Just copy the Application API Key, Application Secret and Application ID details which will be used to write the application code.
Fill the Name and Description of your application in About Link.
Now Click on Website Link to get API Key
Now goto Facebook Integration link and enter any url. Here is where you will get Secret Key.
Enter the Canvas URL and page name. This will be the return URL of your Application.
That’s it You now just successfully create a Facebook Application, now lets work on program
Then click on Save. That’s it we have created a facebook application with an Iframe.
Now Copy Application API Key, Application Secret and Application ID details which will be used to write the application code.
Now download the php library from facebook “http://blog.theunical.com/wp-content/uploads/2010/05/facebook-platform.tar.gz”
Step2: Generate One Time Token to generate Session key
How to generate One Time Session key:
Run below URL to get temporary token for the particular user by logging into Facebook.
https://login.facebook.com/code_gen.php?api_key=API_KEY&v=1.0
Note: Please replace “API_KEY” with your application API key from above page.
Then we will get a temporary token key.

This is one time token key that we can use to generate a permanent session key. Careful! Don’t try to execute this programs many times
Step3: Generate one time session key (permanent session key)
Below is the sample PHP code to generate one time session key.
<?php
// FB_APIKEY is your facebook application api key
// FB_SECRET is your application secrete key
$FB_APIKEY="YOUR_API";
$FB_SECRET="YOUR_SECRET";
$fb = new FacebookRestClient($FB_APIKEY, $FB_SECRET);
$testtoken= "ONETIMETOKEN"; // Replace this value with your Token Value
$result = $fb->call_method('facebook.auth.getSession',
array('auth_token' => $testtoken, 'generate_session_secret' => true));
echo "<br /><pre>";
print_r($result);
echo $session_key = $result['session_key'];
?>
(OR)
For example, the full URL for logging in a user could be:
If the user is redirected to the URL specified by the next parameter, then Facebook grants your application a session. This session is appended to the URL as a JSON-decodable object of the form:
In continuing with the above example, the redirect for a successful login would be:
If the user grants your application the offline_access extended permission, 0 gets returned for expires and the session never expires unless the user removes the application. In this case, you should store the session key so the user doesn’t have to log in the next time he or she launches your application.
Note: The above code will execute only once. We should note down the above session key, This will be used to auto login into the application.
If you don’t save these session key values you should generate other token key to create one time session key.
We can use the token only once.
Step4: Setting Permission for wall
Giving Permission to your application to publish on facebook wall. To give permission just replace the your API key in below URL and execute in browser.
http://www.facebook.com/login.php?api_key=APIKEYXxxxxxxxxxxxxxxxxx&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&req_perms=read_stream,publish_stream,offline_access
Then you must see the below 3 Screens
If you don’t see the below then your call back URL or Canvas URL must be incorrect, please check again your application settings and execute the URL again.
Then on final page, you will see a success message. That’s it you have given permission for read_stream,publish_stream and offline_access.
Step5: Publishing the message on Facebook Wall
PHP Code to create facebook object with onetime session key and publishing the message on Facebook Wall.
<?php
define('FB_APIKEY', 'YOUR_APIKEY');
define('FB_SECRET', 'YOUR_SECRET');
define('FB_SESSION', 'YOUR_SESSION_key');
require_once('facebook-platform/php/facebook.php');
echo "post on wall";
try {
$facebook = new Facebook(FB_APIKEY, FB_SECRET);
$facebook->api_client->session_key = FB_SESSION;
$fetch = array('friends' =>
array('pattern' => '.*',
'query' => "select uid2 from friend where uid1={$user}"));
echo $facebook->api_client->admin_setAppProperties(array('preload_fql' => json_encode($fetch)));
$message = 'From My App: publish steven on facebook';
if( $facebook->api_client->stream_publish($message))
echo "Added on FB Wall";
} catch(Exception $e) {
echo $e . "<br />";
}
?>
Now you will see the post on wall Great.
So thrilling isn’t we can also publish photos videos on wall.
In my next post see how to publish images and videos to facebook is done
http://blog.theunical.com/facebook…/add-picture-on-facebook-wall-using-php/
http://blog.theunical.com/facebook…/post-video-on-facebook-wall-using-php/
See here how to publish on facebook page as a facebook user
http://wiki.developers.facebook.com/index.php/Stream.publish
have a great day
– Steven
Please don’t copy this content to any site. This is fully protected by TheUnical Technologies
Post Laster Updated on 13 March 2011
Comments
301 Comments on 5 Steps to publish on a facebook wall using php
-
Mustafa on
Sun, 1st Nov 2009 7:16 am
-
Ramachandran on
Wed, 11th Nov 2009 7:20 am
-
Steven Robert on
Wed, 11th Nov 2009 11:06 pm
-
Hardik on
Wed, 2nd Dec 2009 6:32 am
-
Steven Robert on
Wed, 2nd Dec 2009 1:13 pm
-
chad james on
Sat, 26th Dec 2009 6:06 am
-
Steven Robert on
Sat, 26th Dec 2009 10:53 pm
-
vishal on
Thu, 31st Dec 2009 9:05 am
-
Steven Robert on
Thu, 31st Dec 2009 11:02 pm
-
vishal on
Fri, 1st Jan 2010 3:42 am
-
Steven Robert on
Fri, 1st Jan 2010 9:45 pm
-
vishal on
Mon, 4th Jan 2010 5:15 am
-
Steven Robert on
Mon, 4th Jan 2010 9:47 pm
-
Vishal on
Mon, 11th Jan 2010 6:41 am
-
Steven Robert on
Mon, 11th Jan 2010 10:53 pm
-
Tomee on
Fri, 15th Jan 2010 3:37 am
-
Steven Robert on
Fri, 15th Jan 2010 10:56 pm
-
Steven Robert on
Fri, 15th Jan 2010 10:58 pm
-
Tomee on
Sat, 16th Jan 2010 9:00 am
-
Steven Robert on
Mon, 18th Jan 2010 12:44 am
-
shyam on
Tue, 19th Jan 2010 9:20 am
-
Steven Robert on
Wed, 20th Jan 2010 4:32 am
-
Steven Robert on
Wed, 20th Jan 2010 4:33 am
-
Maria on
Thu, 21st Jan 2010 7:37 pm
-
Maria on
Thu, 21st Jan 2010 7:40 pm
-
Maria on
Thu, 21st Jan 2010 7:54 pm
-
Steven Robert on
Thu, 21st Jan 2010 10:50 pm
-
Steven Robert on
Thu, 21st Jan 2010 10:51 pm
-
Steven Robert on
Thu, 21st Jan 2010 10:53 pm
-
Tomee on
Fri, 22nd Jan 2010 11:16 am
-
Steven Robert on
Fri, 22nd Jan 2010 10:52 pm
-
Tomee on
Sat, 23rd Jan 2010 6:49 am
-
Steven Robert on
Sat, 23rd Jan 2010 10:56 pm
-
Fabio on
Mon, 25th Jan 2010 11:08 pm
-
Steven Robert on
Mon, 25th Jan 2010 11:10 pm
-
Fabio on
Tue, 26th Jan 2010 7:32 am
-
Steven Robert on
Tue, 26th Jan 2010 10:11 am
-
shyam on
Thu, 28th Jan 2010 5:52 am
-
Steven Robert on
Thu, 28th Jan 2010 9:59 pm
-
shyam on
Fri, 29th Jan 2010 1:15 am
-
faemino on
Fri, 29th Jan 2010 8:31 am
-
Maria on
Fri, 29th Jan 2010 3:24 pm
-
Steven Robert on
Fri, 29th Jan 2010 9:58 pm
-
Rangga on
Sat, 30th Jan 2010 7:24 am
-
Jim on
Sat, 30th Jan 2010 3:48 pm
-
Steven Robert on
Sat, 30th Jan 2010 11:16 pm
-
fede on
Mon, 1st Feb 2010 2:58 pm
-
Sebastien on
Wed, 3rd Feb 2010 10:09 am
-
Steven Robert on
Wed, 3rd Feb 2010 9:57 pm
-
Aziz on
Thu, 4th Feb 2010 9:33 am
-
Kapil Jadhav on
Fri, 5th Feb 2010 9:10 am
-
Aziz on
Mon, 8th Feb 2010 6:07 am
-
roded on
Mon, 8th Feb 2010 11:53 am
-
Keval on
Wed, 17th Feb 2010 8:11 am
-
TheTester on
Fri, 19th Feb 2010 7:16 am
-
Steven Robert on
Fri, 26th Feb 2010 12:22 am
-
Sylvester Faro on
Thu, 4th Mar 2010 6:48 am
-
Steven Robert on
Thu, 4th Mar 2010 9:52 pm
-
abrahan on
Mon, 8th Mar 2010 8:33 pm
-
Steven Robert on
Mon, 8th Mar 2010 10:45 pm
-
Dinesh on
Mon, 15th Mar 2010 4:02 pm
-
navjot singh on
Tue, 16th Mar 2010 6:42 am
-
Steven Robert on
Tue, 16th Mar 2010 9:01 am
-
Dinesh on
Tue, 16th Mar 2010 9:36 am
-
Steven Robert on
Tue, 16th Mar 2010 10:04 am
-
Sylvester Faro on
Thu, 18th Mar 2010 7:13 am
-
Bruno Gomes on
Thu, 18th Mar 2010 10:47 pm
-
Chandan on
Fri, 19th Mar 2010 12:06 am
-
Chandan Singh on
Fri, 19th Mar 2010 2:20 am
-
Steven Robert on
Fri, 19th Mar 2010 4:26 am
-
Steven Robert on
Fri, 19th Mar 2010 4:29 am
-
Steven Robert on
Fri, 19th Mar 2010 4:51 am
-
bruno gomes on
Fri, 19th Mar 2010 11:00 am
-
tippi on
Fri, 19th Mar 2010 1:57 pm
-
Steven Robert on
Fri, 19th Mar 2010 10:59 pm
-
Steven Robert on
Fri, 19th Mar 2010 10:59 pm
-
Nick on
Wed, 24th Mar 2010 3:16 am
-
Luca on
Wed, 24th Mar 2010 10:16 am
-
Luca on
Wed, 24th Mar 2010 6:45 pm
-
Sammy on
Thu, 25th Mar 2010 3:17 am
-
Steven Robert on
Thu, 25th Mar 2010 10:20 am
-
Steven Robert on
Thu, 25th Mar 2010 12:00 pm
-
Saurabh on
Sun, 28th Mar 2010 1:52 pm
-
Steven Robert on
Sun, 28th Mar 2010 10:46 pm
-
kirochi on
Mon, 29th Mar 2010 12:10 pm
-
Mirza on
Tue, 30th Mar 2010 11:52 pm
-
Steven Robert on
Wed, 31st Mar 2010 4:09 am
-
Rami on
Tue, 6th Apr 2010 8:11 am
-
sunetra on
Fri, 9th Apr 2010 6:57 am
-
Steven Robert on
Sat, 10th Apr 2010 9:58 am
-
sunetra on
Sun, 11th Apr 2010 2:00 am
-
Steven Robert on
Sun, 11th Apr 2010 4:31 am
-
Omar Plummer on
Tue, 13th Apr 2010 11:24 pm
-
Iva on
Fri, 16th Apr 2010 9:29 am
-
newbie on
Thu, 22nd Apr 2010 6:31 am
-
darrasin@freedom.com on
Fri, 23rd Apr 2010 5:45 pm
-
Rio MobineSSia on
Fri, 23rd Apr 2010 11:57 pm
-
Steven Robert on
Sun, 25th Apr 2010 8:02 am
-
Steven Robert on
Sun, 25th Apr 2010 8:22 am
-
BKC on
Sun, 25th Apr 2010 1:20 pm
-
newbie on
Sun, 25th Apr 2010 1:22 pm
-
Steven Robert on
Sun, 25th Apr 2010 9:34 pm
-
Steven Robert on
Sun, 25th Apr 2010 9:36 pm
-
Felix Gomez Jr on
Mon, 26th Apr 2010 12:25 pm
-
Steven Robert on
Mon, 26th Apr 2010 9:42 pm
-
Aarif on
Wed, 28th Apr 2010 9:13 am
-
Steven Robert on
Wed, 28th Apr 2010 10:47 pm
-
dina on
Sun, 2nd May 2010 3:00 am
-
dina on
Sun, 2nd May 2010 9:00 am
-
Steven Robert on
Sun, 2nd May 2010 9:01 am
-
dina on
Mon, 3rd May 2010 3:10 am
-
Girl games on
Wed, 5th May 2010 6:03 am
-
Aziz on
Tue, 11th May 2010 5:48 am
-
Steven Robert on
Tue, 11th May 2010 8:19 am
-
Aziz on
Tue, 11th May 2010 9:07 am
-
Steven Robert on
Tue, 11th May 2010 11:35 pm
-
Aziz on
Wed, 12th May 2010 5:05 am
-
nikhil on
Thu, 13th May 2010 8:10 am
-
Steven Robert on
Thu, 13th May 2010 8:35 am
-
nikhil on
Thu, 13th May 2010 8:45 am
-
Steven Robert on
Thu, 13th May 2010 10:42 am
-
Edgar on
Mon, 17th May 2010 10:06 am
-
lilongsy on
Tue, 18th May 2010 11:37 am
-
lilongsy on
Tue, 18th May 2010 11:38 am
-
lilongsy on
Tue, 18th May 2010 11:43 am
-
Namalak on
Wed, 19th May 2010 8:42 am
-
Kuldeep singh on
Fri, 21st May 2010 4:28 am
-
Krishna on
Mon, 24th May 2010 8:23 am
-
Anulya on
Fri, 11th Jun 2010 5:16 am
-
saran on
Tue, 15th Jun 2010 10:05 am
-
kamarul on
Wed, 16th Jun 2010 6:49 am
-
Junior on
Mon, 21st Jun 2010 4:40 am
-
piv64 on
Mon, 21st Jun 2010 8:47 am
-
Steven Robert on
Mon, 21st Jun 2010 11:03 pm
-
Steven Robert on
Mon, 21st Jun 2010 11:04 pm
-
piv64 on
Tue, 22nd Jun 2010 5:39 am
-
Junior on
Tue, 22nd Jun 2010 10:08 am
-
Steven Robert on
Wed, 23rd Jun 2010 12:13 am
-
Junior on
Wed, 23rd Jun 2010 7:02 am
-
Steven Robert on
Wed, 23rd Jun 2010 10:11 am
-
orkut scraps on
Thu, 24th Jun 2010 3:20 pm
-
Mr Blass on
Sat, 26th Jun 2010 9:50 pm
-
Junior on
Sun, 27th Jun 2010 12:44 pm
-
Ernestas on
Mon, 28th Jun 2010 6:34 pm
-
dinesh on
Wed, 7th Jul 2010 3:27 pm
-
Joomla Outsource India on
Sat, 17th Jul 2010 6:39 am
-
Steven Robert on
Sun, 18th Jul 2010 5:15 am
-
Joomla Outsource India on
Sun, 18th Jul 2010 11:07 am
-
Jeff on
Thu, 22nd Jul 2010 5:40 pm
-
Jeff on
Thu, 22nd Jul 2010 6:02 pm
-
Steven Robert on
Thu, 22nd Jul 2010 11:44 pm
-
Jeff on
Sat, 24th Jul 2010 9:41 am
-
Joomla Outsource India on
Sat, 24th Jul 2010 11:38 pm
-
Yaco Zaragoza on
Fri, 6th Aug 2010 2:58 pm
-
dinesh pal on
Wed, 18th Aug 2010 7:44 am
-
dinesh pal on
Wed, 18th Aug 2010 7:48 am
-
Steven Robert on
Wed, 18th Aug 2010 1:42 pm
-
dinesh pal on
Thu, 19th Aug 2010 2:59 am
-
dinesh pal on
Thu, 19th Aug 2010 8:00 am
-
Steven Robert on
Fri, 20th Aug 2010 11:54 pm
-
dinesh pal on
Mon, 23rd Aug 2010 1:07 am
-
Steve on
Thu, 26th Aug 2010 7:15 am
-
Malcom on
Mon, 30th Aug 2010 3:47 pm
-
fd on
Thu, 9th Sep 2010 5:47 am
-
Khushal on
Thu, 9th Sep 2010 7:41 am
-
Ravi on
Fri, 10th Sep 2010 4:36 pm
-
Ravikumar on
Tue, 14th Sep 2010 11:12 pm
-
mukhan86 on
Mon, 20th Sep 2010 7:50 am
-
Shane Fernando on
Tue, 28th Sep 2010 11:40 am
-
zootyo on
Mon, 11th Oct 2010 5:16 am
-
Pieter on
Mon, 11th Oct 2010 5:49 am
-
shevy on
Tue, 12th Oct 2010 12:12 pm
-
Sumit Singhal on
Thu, 14th Oct 2010 1:10 am
-
Steven Robert on
Thu, 14th Oct 2010 11:21 pm
-
Furqan on
Fri, 15th Oct 2010 4:35 pm
-
shevy on
Sun, 17th Oct 2010 11:20 am
-
Sumit Singhal on
Tue, 19th Oct 2010 2:42 am
-
Daniel on
Fri, 29th Oct 2010 3:23 am
-
praveenkumar on
Fri, 29th Oct 2010 5:48 am
-
Gopinath on
Sat, 20th Nov 2010 7:55 am
-
baljeet on
Mon, 22nd Nov 2010 8:31 am
-
Kim an on
Thu, 25th Nov 2010 4:24 am
-
baljeet on
Sat, 27th Nov 2010 3:33 am
-
baljeet on
Sat, 27th Nov 2010 6:25 am
-
edan cohen on
Sun, 28th Nov 2010 2:22 pm
-
Happismiley on
Mon, 29th Nov 2010 3:55 am
-
Steven Robert on
Mon, 29th Nov 2010 10:56 pm
-
bod on
Tue, 30th Nov 2010 12:04 am
-
baljeet on
Tue, 30th Nov 2010 3:10 am
-
art on
Tue, 30th Nov 2010 9:56 am
-
happismiley on
Sat, 4th Dec 2010 1:45 am
-
baljeet on
Mon, 6th Dec 2010 1:25 am
-
happismiley on
Mon, 6th Dec 2010 4:16 am
-
baljeet on
Tue, 7th Dec 2010 11:36 am
-
How to post to other user’s wall in Facebook. – Moishe Beshkin on
Mon, 13th Dec 2010 6:57 am
-
gaurav on
Mon, 13th Dec 2010 3:22 pm
-
baljeet on
Wed, 15th Dec 2010 1:53 am
-
arduinomark on
Thu, 16th Dec 2010 11:15 am
-
Tomas Teicher on
Tue, 21st Dec 2010 11:47 am
-
baljeet on
Wed, 22nd Dec 2010 1:40 am
-
Rajkumar on
Wed, 22nd Dec 2010 1:59 am
-
Steven Robert on
Wed, 22nd Dec 2010 9:55 pm
-
Steven Robert on
Tue, 28th Dec 2010 11:11 pm
-
arduinomark on
Mon, 3rd Jan 2011 5:13 am
-
Sundar Thirugnanam on
Mon, 3rd Jan 2011 7:27 pm
-
mbu on
Tue, 11th Jan 2011 7:18 am
-
Steven Robert on
Tue, 11th Jan 2011 11:31 pm
-
Johnny on
Mon, 24th Jan 2011 7:01 pm
-
Prashant Parashar | links for 2011-01-26 on
Wed, 26th Jan 2011 9:06 pm
-
james on
Fri, 28th Jan 2011 7:23 am
-
Power Supply Tester on
Sat, 29th Jan 2011 10:33 am
-
mbu on
Mon, 31st Jan 2011 1:14 am
-
madmax on
Mon, 31st Jan 2011 11:51 am
-
Vicky on
Tue, 1st Feb 2011 5:47 am
-
Steven Robert on
Tue, 1st Feb 2011 1:49 pm
-
Steven Robert on
Tue, 1st Feb 2011 1:53 pm
-
Anton on
Thu, 3rd Feb 2011 9:53 am
-
Tejas on
Tue, 8th Feb 2011 3:43 pm
-
Nagarjuna on
Fri, 11th Feb 2011 8:06 am
-
Tokio Hotel on
Mon, 14th Feb 2011 6:35 am
-
Steven Robert on
Mon, 14th Feb 2011 10:12 pm
-
lizzy on
Tue, 15th Feb 2011 5:25 am
-
Steven Robert on
Tue, 15th Feb 2011 11:16 pm
-
Facebook Application Bookmark Url | More More Pics on
Fri, 18th Feb 2011 1:01 pm
-
Joe Davila on
Sat, 19th Feb 2011 8:56 pm
-
Yogi on
Tue, 22nd Feb 2011 4:48 am
-
Mukta on
Thu, 24th Feb 2011 5:43 am
-
Steven Robert on
Thu, 24th Feb 2011 11:38 pm
-
Mukta on
Fri, 25th Feb 2011 2:30 am
-
Mukta on
Fri, 25th Feb 2011 4:23 am
-
Steven Robert on
Fri, 25th Feb 2011 11:27 pm
-
vivek on
Sun, 27th Feb 2011 1:59 pm
-
fern on
Tue, 8th Mar 2011 9:09 am
-
Steven Robert on
Tue, 8th Mar 2011 11:39 pm
-
khadija on
Wed, 9th Mar 2011 6:22 am
-
fern on
Thu, 10th Mar 2011 1:04 am
-
nakres on
Fri, 11th Mar 2011 10:43 am
-
Steven Robert on
Sun, 13th Mar 2011 3:01 am
-
ecommerce developer on
Mon, 14th Mar 2011 1:03 am
-
khadija on
Tue, 15th Mar 2011 2:07 am
-
Steven Robert on
Tue, 15th Mar 2011 2:33 am
-
khadija on
Tue, 15th Mar 2011 6:42 am
-
Steven Robert on
Tue, 15th Mar 2011 10:48 pm
-
khadija on
Thu, 17th Mar 2011 7:41 am
-
Michael Lasell on
Thu, 17th Mar 2011 4:09 pm
-
Steven Robert on
Fri, 18th Mar 2011 2:14 am
-
Pankaj on
Tue, 22nd Mar 2011 7:28 am
-
Decorative Concrete on
Wed, 23rd Mar 2011 2:38 am
-
John Wolf on
Wed, 23rd Mar 2011 1:30 pm
-
Steven Robert on
Sat, 26th Mar 2011 9:27 am
-
Alan on
Mon, 28th Mar 2011 5:35 am
-
John Wolf on
Wed, 30th Mar 2011 8:52 am
-
Majox on
Sat, 2nd Apr 2011 7:22 pm
-
Jeremy on
Sun, 3rd Apr 2011 12:46 pm
-
Steven Robert on
Mon, 4th Apr 2011 2:31 am
-
Majox on
Mon, 4th Apr 2011 10:23 am
-
baljeet on
Tue, 5th Apr 2011 2:52 am
-
Eugin on
Fri, 8th Apr 2011 10:24 am
-
SK Imdad on
Wed, 13th Apr 2011 4:19 pm
-
Steven Robert on
Wed, 13th Apr 2011 10:58 pm
-
Filipi on
Wed, 11th May 2011 9:41 am
-
Filipi on
Wed, 11th May 2011 11:50 am
-
Steven Robert on
Wed, 11th May 2011 11:32 pm
-
John Wolf on
Fri, 13th May 2011 6:25 am
-
H on
Mon, 16th May 2011 11:58 am
-
Atiq on
Wed, 25th May 2011 2:16 am
-
Amedeo on
Sat, 28th May 2011 3:11 am
-
pratap on
Tue, 31st May 2011 4:12 am
-
Troy on
Wed, 1st Jun 2011 8:55 am
-
Steven Robert on
Wed, 1st Jun 2011 10:09 pm
-
bharat on
Thu, 9th Jun 2011 3:42 am
-
Malay on
Fri, 10th Jun 2011 1:08 am
-
Steven Robert on
Fri, 10th Jun 2011 10:50 pm
-
Milos on
Wed, 15th Jun 2011 7:50 am
-
Lucijan on
Wed, 15th Jun 2011 5:35 pm
-
John on
Fri, 17th Jun 2011 3:24 am
-
Steven Robert on
Fri, 17th Jun 2011 10:45 pm
-
Roufaa on
Wed, 22nd Jun 2011 11:51 pm
-
John on
Sat, 25th Jun 2011 10:59 pm
-
Chirag on
Wed, 6th Jul 2011 4:05 pm
-
กเก้ด on
Sat, 9th Jul 2011 6:46 am
-
John on
Sat, 9th Jul 2011 12:50 pm
-
Obed on
Sat, 9th Jul 2011 1:14 pm
-
ketan on
Wed, 27th Jul 2011 2:02 am
-
allan rivera on
Tue, 2nd Aug 2011 12:24 am
-
Novrizal on
Thu, 25th Aug 2011 6:43 pm
-
Steven Wall on
Thu, 25th Aug 2011 11:03 pm
-
aaron on
Fri, 9th Sep 2011 10:31 am
-
Steven Wall on
Sun, 11th Sep 2011 1:33 am
-
sanjay on
Wed, 21st Sep 2011 12:25 am
-
Steven Wall on
Wed, 21st Sep 2011 11:01 pm
-
Mithun on
Mon, 26th Sep 2011 5:28 am
-
Steven Wall on
Mon, 26th Sep 2011 11:04 pm
-
Vikash Sharma on
Thu, 29th Sep 2011 8:36 am
-
Mit on
Sat, 10th Dec 2011 8:19 am
-
Nischal Tiwari on
Fri, 10th Feb 2012 6:03 am
-
Jose on
Tue, 28th Feb 2012 6:00 am
-
Sanjay Soral on
Tue, 28th Feb 2012 6:51 am
-
Jim on
Fri, 9th Mar 2012 5:15 pm
-
Kevin on
Tue, 8th May 2012 3:32 am
-
PARUL on
Fri, 11th May 2012 9:20 am
Excellent:
Here is another way to Publish on Facebook Wall Using JSON using Coldfusion:
http://blog.abusalah.info/2009/05/publish-on-facebook-wall-using-json-fb.html
Nice script, thanks for your script…..
when i use this script .I am getting the error as 104(incorrect signature).
And we can able to run the script suceessfully upto step 4.But i am struck in the STEP 5 because of this error .
Do you aware of this error?
How to fix this.
Any input is appreciated.
After step4 did you see the privilege screen from facebook.
we need to give permissions to publish on facebook. Let me know if you have any questions.
hello,
i have followed the instruction word by word and i have also succed.But I have one doubt thats is where should I use that two script.
I am developing an iphone application which connect to facebook.thats i will login on facebook through my iphone and after login i want to publish on my wall as well as user walls directly.I hope you understand what my doubt is.
Yes u can do that. If you have the api key and secret key. You need to save this keys in ur application.
Hey I created a facebook application for my blog called QIT Interact, The problem I’m running into is I’m new to all this etc and I’m trying to work out if there is way that I can have my application published to feeds say when a new post has been posted etc rather then looking up the application etc. Ideally what I’m wanting to do is rig it so it will always send a message to streams any help would be greatly appreciated
Yes, We can. what kind of application you are building
I am trying to publish my offline data on facebook but its not giving me any response.. below is my script .. please give me solutions .
api_client->session_key = $_REQUEST['fb_sig_session_key'];
$facebook->require_frame();
$user = $facebook->require_login();
$userinfo = get_prints($user);
$name = $userinfo[0]['title'];
$description = $userinfo[0]['description'];
$attachment = array(‘name’ => $name, ‘href’ => ‘http://apps.facebook.com/vishpoint/’, ‘description’ => $description, ‘media’ => array(array(‘type’ => ‘image’, ‘src’ => ‘http://www.jaisiyaram.com/adv/banners/23-1-1260415655.jpg’, ‘href’ => ‘http://apps.facebook.com/vishpoint/’)));
$action_links = array(array(‘text’ => $name, ‘href’ => ‘http://apps.facebook.com/vishpoint/’));
$attachment = json_encode($attachment);
$action_links = json_encode($action_links);
$has_permission = $facebook->api_client->users_hasAppPermission(“publish_stream”);
//echo $has_permission;
$ans=$facebook->api_client->stream_publish(“Testing.. “,$attachment,$action_links);
if($ans){
echo “Added on FB Wall”;
}else{
echo “Not Added on FB Wall”;
}
}catch(Exception $e) {
echo $e . “”;
}
?>
You cannot connect to facebook offline.
Hi Steven, Actually i want to post my data from my pc on the facebook wall.. like image, title and description by above script…Is it possible? how?
Yes but the image should be in a public path like it should be accessible from any where.
HI steven,
I have admin section on my website. I am updating news content on website daily. I want to publish same content on my facebook account wall. What I want is when I submit content in my websites’s admin area, it should also update facebook wall with same contents.
I have set up facebook application and grab the API Key and other required information. I am using iframe and not fbml.
I am using stream_publish() function.
Problem is here when I submit data using stream_publish, it redirects me to login page.
Is there any method through which I can login to facebook and publish content to my facebook wall.
Below is the code.
require_frame();
$user = $facebook->require_login();
$attachment = array(‘name’ => $name, ‘href’ => $link, ‘description’ => $description, ‘media’ => array(array(‘type’ => ‘image’, ‘src’ => $imagelink, ‘href’ => $link)));
$action_links = array(array(‘text’ => $name, ‘href’ => $link));
$attachment = json_encode($attachment);
$action_links = json_encode($action_links);
$facebook->api_client->stream_publish($description,$attachment,$action_links);
?>
Please help.
Thanks in advance.
Hello Vishal,
You need to complete Step 2, 3, 4 to create a one time session key and give permission to publish on wall. so that next time it will not ask you to login to facebook.
Let me know if you done these correctly.
Hello
I tried to perform all steps mentioned below.
1) I have created application as mentioned.
2) I have retrived one time session key.
3) I have granted permission as well.
4) In application setting, I have canvas call back url, this would call the script in step 5.
Now what I do is I logged out from facebook. Then I typed url in address bar as http://apps.facebook.com/theunicalblogtest/
This shows me “Sign up for Facebook to use Blog TheUnical.”
What I am doning wrong here? can you please let me know here?
Hi Vishal,
Why you want to type this URL “http://apps.facebook.com/theunicalblogtest/”. you can just execute your program.
Hi there,
the code from the step 3 where should be copied to run, ‘couse saving to a file and just run it does not gives you a valid response.
Just Copy the php code and replace with your keys and execute to generate a one time session key. Tomee, you need to execute this only once, if you try to execute this 2nd time you will get some errors.
Tomee, If you get errors then try again from step2.
i obtained the one time code Steven, and the API code and secret also. When I run the file it gives me the “FacebookRestClient” undefined function error, which is kinda normal I think ‘couse it is nowhere defined in the php file.
Hi Tomee here is the same code that is working for my id , replace with your’s and try. http://blog.theunical.com/?attachment_id=267142.
let me know if you still have any issues.
I follow the instruction but i have a problem when i am trying to generate session since there is class page in not included in STEP 3 so firstly is say class not found and even after adding the related class now is saying
Class ‘Facebook’ not found in /var/vhosts/apartmentsneakpeeks/httpdocs/facebook-platform/php/facebookapi_php5_restlib.php on line 82
Rest was fine but in the last due to session value is “” i could not make the post done.
Will you please mail me regarding this.
Thanks and Regards,
SHyam
Shyam did you tried downloading the code from here? http://blog.theunical.com/?attachment_id=267142
Shyam did you tried downloading the code from here?
http://blog.theunical.com/?attachment_id=267142
Steven, I cannot execute step 3. Is the php code supposed to be executed on a server? I have plugged in my values, but I get php parsing errors.
Plus, line 11 in step 3 should be:
$fb = new FacebookRestClient($FB_APIKEY, $FB_SECRET);
FB_APIKEY and FB_SECRET are php variables. And should the code not include the facebook php library? I am very confused.
And finally, this link does not show any code
There is a link that you can download from, check again.
This is that link http://blog.theunical.com/wp-content/uploads/2010/01/fb_app.zip
Maria, This should be replaced by facebook secret key and facebook app key
Yes Maria, the code should be executed on server.
Thank you steven I managed to publish on my wall finally
can you help in making publish possible from my app ?
Hi Tomee, You can just create a Iframe of your existing application and try it in Facebook App.
Steven what I would like to do is, anyone who uses my facebook app and clicks on a link to be able to publish on his own wall a message like “come and play this” or that game
I was looking on the facebook dev forums but it’s a mess majority of the examples are using deprecated functions, and no working example can be found
disappointing
Tomee, To Publish on Users you need to first generate a one time session key and later they need to give authentication, so that you can publish on their wall.
Hi,
i’m enchanted … wow , your article “5 Steps to publish on a facebook wall using php” is the unique resurce that explane how to publish on Facebook wall without use form login.
I googled a lot and fortunately i found your blog.
But i’m also curious,so i would ask you :
1. How did you find this solution? and all the links used to open a session? On developer Facebook section i could not find nothing about. Are maybe secret links ? ![]()
2. And, is possible to publish on a Fan-page wall instead of User wall ? If yes, how can i customize it?
Thanks a lot.
Bye from Italy
Fabio
Hi Fabio,
Even I too have to do some research like you when I got requirement to publish on a wall and I tried a lot at last I was successful to publish on wall. So I thought, since there are no post that truly describes how to publish on a wall. So I have to write this post. The solution is in facebook but not on a single page you need to read some 20- 40 pages and try lot of examples then you will get.
Yes, you can publish on Fan-page too, but you need to get permissions of that page too.
- Steven
Good…i have permission…i’m administrator of the Fan Page.
Can you give me some php code suggestion?
Hi Fabio,
Here is the example PHP code and the screenshots in my next post to publish on a Facebook fan’s page.
http://blog.theunical.com/facebook-integration/simple-steps-to-publish-on-facebook-fan-page-using-php/
If you still have any difficulties we can develop any facebook applications for you.
-Steven
Hello Steven Robert,
Thanks for reply, thanks for write such page to helps other.
Perhaps i was wrong some where now i can post without log in.
Will you please tell me how to add image /url along with the post and what are the purpose of this line ?
“‘query’ => “select uid2 from friend where uid1={$user}”));”
is this related to our table or FB’s table.
Thank you in advance and waiting for your reply.
I was late to write this because i could not test the application after your message.
Today i did .
Regards,
SHyam
Hi Shyam, That is a facebook table.
In my next post see how to publish images and videos to facebook is done
http://blog.theunical.com/facebook…/add-picture-on-facebook-wall-using-php/
http://blog.theunical.com/facebook…/post-video-on-facebook-wall-using-php/
Hello Steven ,
I am very pleased to see your reply and next blog for video and photo.
Thanks for all of them.
Steven i have one more query—-
can i sync the wall post to my twitter account ? Mean can i directly link these posting as a twitter tweet.
I will be very thankful for your reply.
Regards,
SHyam
Just thanks for all your articles about Facebok conection from PHP. Great resource and nice job.
Steven, I tried all of your code for step 3, and I cannot get it to work …. grrrrrr!!! I download the php library from facebook to my server. I copy the generatesession.key.php to the same directory on my server and name it index.php. Then I try to call my application from Facebook, but I get error message. What am I doing wrong?
Hi Maria,
Did you created the facebook application, as I described in Step1? Iam able to publish with a new account in 10 mins. May be you are doing something incorrect.
Also please make sure that you enter any working URL in Canvas call back URL and Connect URL. if this is missing then the application will not work.
I have 2 questions as below:
1. What is the real purpose of fetching friend list on your code, since I didn’t see any relation with it main topics; to put something on our wall.
2. Is there something that need to change from your code if I want to implement it on my mobile web ?
Thx 4 sharing..
Thank you! After many days of search, google’ing and testing this page was the key to posting messages to an offline user
Rangga, this code work’s perfect on mobile web too.
genius you save my week work, the documentation of facebook is a bullshit and you explain us so clear and concise.
Thank you very much.
Fede from rosario,argentina.
Success.!!!!!!!!!!!!!!11
Thank you so much for this code. I have been reading the facebook wiki for days trying to achieve this and they’ve managed to confuse me beyond belief. I was able to connect thanks to you!
I do have one question though, is the one-time code a link between the application and the facebook account? If I give my users the ability to post on their walls from my website can I use the token (assuming I save it somewhere and get their permission) indefinitely? I’m trying to figure out if the session key will expire.
Thanks again!
Sebastien , do you want to post users on your wall. If so, you can create a simple app and give to your users. If the users has to post on their own wall then you can simply use any bookmarking tool like Shareit, Addit etc.
I am stuck on step 3. I am assignning the apikey, secret and token, but when i run it i am not receiving the session key.
Hi Thank you for the code and description. The steps and code work like charm. I am successful implementing this but just wanted to know if there is a way to ask user ib a popup if they want to publish or skip.
Thank you a tons,
Kapil
Ohh i am so stupid ))) Thx it worked. this method is great!!
thanks for this article
you save my day…man, facebook framework is quite pain in the neck…hehehe
hi Steven
I have write message on my application wall
Your coding is used to message display on user wall
have u help me …??
thanks in advance
Great tutorial but I have one question. What if want to make not temporary session key but something to call stream.publish in background(for example as a cron job). In such scenario I can’t ask user for session key so I need some kind of persistent session key. How can I obtain it?
hello TheTester, Do u want to publish on user own wall, if yes then there in no need of any session key, you can just any bookmarking tool for this, like I used one in this blog.
This is GREAT… after wasting hours on <> Facebook API docs, I got this working in less than 5 minutes.
Like “TheTester”, I will be using this on a Cron Job to publish on my own wall… I have same concerns for “how long will the session key be valid?”… But I guess I will have to monitor “invalid session key” publishing errors and then generate a new session key…
Hi Faro, The session key will be valid until something unusual happens, Like if you hit facebook continuously , like in 1min you tried to hit some 50 times then that key will be invalid then you need to generate again a new key. If not then it will be valid for a longer time.
Hey!, when i try 2 and 3 steps, i get this error:
Canvas Callback URL must point to a directory (i.e., end with a “/”) or a dynamic page (i.e., have a “?” somewhere).
Connect URL must point to a directory (i.e., end with a “/”) or a dynamic page (i.e., have a “?” somewhere).
do you know why appears the error? and… can you help me to solve it?
Hi Abrahan, This Canvas URL and connect URL should be a publicly accessible URL.
Hi Steven,
I have follow all five steps
I have done with Publish to wall functionality.
Post has also display on users wall
But I am missing result means attachment object text, href,image and media on publish poppup….
I am used Asp.net MVC Framwork 2.0
Net Facebook API Client.
and in my old application Publish to wall functionality not working bcz of Facebook stop supporting to fb.connect.confirmDialog…method.
Please help me
its a very nice post, but i am unable to get 100% out of it. Can you let me know where the code generated by user as permanent code for my site need to be used.
each time after the permission if try to publish i get the below error.
‘Session key invalid or no longer valid’
please guide me where i am doing the wrong implementation
any kind of fast help will be very thankful
regards
navjot
Hi Navjot, After you execute Step3: Generate one time session key , on your browser you can see a session key printed. This is what the Permanent session key. This key will be in two parts separated by a hi-fen. Let me know if you still have any issues.
Hi Steven,
Pls help me
Dinesh The URL need to be Public Available URL and not a local URL, Check it once. Are you trying with a public URL?
This code works fine in posting to my profile’s wall.
If I setup a facebook page (http://www.facebook.com/pages/create.php), that page will have its own wall.
What do I need to change on these steps to post to that page’s wall?
First of all thanks for this tutorial.
I have one question:
I’ve made all the steps and its all working but.
My facebook name is:
Bruno Gomes
http://www.facebook.com/bmag2009
My Application name is
Creative-mood
http://www.facebook.com/apps/application.php?id=356981166204&ref=nf
My Fan page is:
bmag-01
http://www.facebook.com/pages/bmag-01/335140057869
When i run the script to publish to wall or the the fan page wall all goes well but it says:
Bruno Gomes From My App: publish steven on facebook
3 minutes ago via creative-mood · Comment · Like
And i wanted to say:
Creative-mood From My App: publish steven on facebook
3 minutes ago via creative-mood · Comment · Like
Is there any chance to do that.
I wanted to be the application creative-mood to make the post not myself..
Sorry for my english:
Thanks in advance
Hi Steven
I went through all 5 steps n used the code. Guess what it worked very smoothly
The only issue is it works only on my profile. my friend who is also using the application is not getting any messages on the Wall. Do u have any idea y?
hi Steven
I did everything as per the post and it worked on my id. but if anybody other than me tries it using their id it does not post the messages on the wall. could u please explain how do i achieve this.
Hi Sylvester Faro, Just get the pageid or fan page id or where ever you want to publish get that ID and set that in target id
Hello Chandan, This will be published on your wall and not their wall because you can set everything from your User, and given permission to your wall.
Hi Bruno, Hope this helps
http://tech.karolzielinski.com/publish-post-of-facebook-page-wall-as-a-page-not-a-user-python-facebook-rest-api
Thanks Steven for the fast reply.
I Dont know python
so i problably give up.
Thanks..
Hi Steven. Nice post! When I run the code to generate the session key, I get a “Notice: Uninitialized string offset: 0″. I have no idea why this appears. And also, I don’t get any value back from call_method ? Why is that ?
Tippi Try this code http://blog.theunical.com/wp-content/uploads/2010/01/fb_app.zip
Ok Bruno I will write up a post for you.
Great tutorial, thanks steven!
I have gotten all the way to Step 5, where it’s time to make my first wall post. Unfortunately the following error message appears:
post on wallexception ‘FacebookRestClientException’ with message ‘This method call must be signed with the application secret (You are probably calling a secure method using a session secret)’
Can anybody provide insight? I have verified application URLs specified, permissions granted, session key obtained, etc. Baffling. Please note that I am not very proficient in PHP I just managed to copy enough code to get it working up to step 5…
Hi Steven!
as Bruno, I need to publish post on Facebook Page wall as a Page (not a user).
Let me know when you will post the solution!!
Thank you
hi ,
i am unable to generate the permanent session key i have followed all the steps but somhow whn i tried executing step 3 .. it does not generate a session key can u please tell me what is going wrong ?
am eagrly awating your reply
thanxz
Sammy, what’s the error that you are getting?
Hello Bruno and Luca,
I was little busy this week, I was in Sun Tech Days 2010, at last, here is the post that helps you to publish on fan page as fan user using php, Let me know if you have still any issues. http://blog.theunical.com/facebook-integration/publish-on-facebook-fan-page-as-fan-user-using-php/
Hi Steven,
I could not post on the wall despite following the steps given on the blog. Please help. I am using the one time session key which is generated using the token code. Also , please let me know, how will the other users who are using my app will be able to post on their walls so that their frnds will get updates ?
Saurabh, check all the steps and all the fields of screen shots again. It will work. Other users need to give permission to their wall or Use some bookmarking tools, so that they can publish on their walls.
This code is good
require_once ( ‘php / facebook.php’), / / the two folders you have downloaded it mounted the server
$ api_key = “xxxxxxxxxxxxxxxxxxxxxxxxxx”;
$ secret_key = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
$ facebook = new Facebook ($ api_key, $ secret_key);
$ user = $ facebook-> require_login ();
$ message = ‘news http://www.mega.cl test’;
$ has_permission = $ facebook-> api_client-> users_hasAppPermission (publish_stream “);
/ / The user must give permission for your application publishes information on its wall.
if ($ has_permission)
(
$ facebook-> api_client-> stream_publish ($ message);
echo ‘posted the message’. $ message;
)
else (
$ address = “http://www.facebook.com/connect/prompt_permissions.php?api_key =”. $ api_key. “& v = 1.0 & next = http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&display = popup & ext_perm = read_stream, publish_stream & enable_profile_selector = 1 & profile_selector_ids = “. $ user;
header ( “location: $ address”);
)
?>
dear steven
i have already follow the instruction but i get error
can you help me ?
i just need the simple code
1. Status Update
so when ppl use the aplication it would like :
Name : i’m so busy
posted from mysite
Mirza, What’s the error you got?
Thank you so much,
I spent so long trying to do it,
and I could not have done this without this great guide.
oh ye and there was a small bug i found:
on step 3 this line is wrong:
$fb = new FacebookRestClient(FB_APIKEY, FB_SECRET);
and should be change to (since this parameters are not defined):
$fb = new FacebookRestClient($FB_APIKEY, $FB_SECRET);
hie steven ,
Your above 5 steps are really helpfull for me thanks a lot !…..
Now i want to display the images on Tab i have also mention the tab name and tab URL still it is not showing the content ..please help me…..
Regards,
Sunetra
Hi Sunetra, which method you used to post on tabs?
hello steven ,
im using static FBML ..can we use iframe tags in Tab Canvas…..
eg i have created my tab ” demophoto” and i want to display my data into the ” demophoto” i can use iframe ?
Sunetra, You can use FBML. Need to check which is used to post on tabs.
Thanks a lot. At first I found it confusing, (I’m new to facebook dev) but I got the hang of it. Extremely helpful
Steve, I thank you so much!
hi steve nice tutorial,
i just have a small problem.
i was on step four and when i replaced the values with my API KEYS this is what i get:
API Error Code: 100
API Error Description: Invalid parameter
Error Message: Param fbconnect must be a boolean
Please please help me.
What am i doing wrong?
this is the one that i should be replacing right?
–> APIKEYXxxxxxxxxxxxxxxxxx
please guide me, im almost there but not quite. thanks in advance
Steve – great tutorial and I thank you for the time and detail you put into it. I am having trouble with step #3 generating the session key. I downloaded your script generatesession.key.php put in my api key and secret but get the following error when executing:
Fatal error: Uncaught exception ‘FacebookRestClientException’ with message ‘Invalid parameter’ in /web/sites/widgets/facebook/facebook-platform/facebook-platform/php/facebookapi_php5_restlib.php:3025
Any advice is greatly appreciated.
I’m developing mobile web application (xHTML) in PHP which already success connected to fb.
But I still confuse for asked permission (Step 4 on your guide above) in mobile way.
Do you know how to adopt your Step #4 above to be run on mobile micro browser?
Thx in advance.
Rio You can execute Step4 in mobile version too
Darrasin try the other link I updated in post for Step3.
Love the blog. Step 4 failed with error fbconnect must be boolean. Replacing true with 1 seems to work.
steve, u skipped my question ![]()
help please. thanx
Yes BKC it seems facebook changed its api for true/false to 1/0.
Yes Uber,
replace true with number 1 and try.
Hi Steven, do you have any idea how to post the message on the wall of a fan page?
Felix, Check this post http://blog.theunical.com/facebook-integration/publish-on-facebook-fan-page-as-fan-user-using-php/ to Publish on Facebook Fan Page as fan user
hi steven
very nice post thanks man. I am facing one issue.
I want is abuot creating avatar and people can come and like or dislike any avatar. even this avatar is created by a friend or not.
now i want my app to publish on person A wall, if person B comes and like his/her avatar in the app & both are not even friends.
Both person A and B have given exntended permission to the app also and are not friend.
I am using following publish stream code
$facebook->api_client->stream_publish($message,null,null,$personA_id,$app_id)
Its showing this error
post on wallexception ‘FacebookRestClientException’ with message ‘The user hasn’t authorized the application to perform this action’ in /home/jill/web/php/facebook-platform/php/facebookapi_php5_restlib.php:3374 Stack trace: #0 /home/jill/web/php/facebook-platform/php/facebookapi_php5_restlib.php(932): FacebookRestClient->call_method(‘facebook.stream…’, Array) #1 /home/jill/web/public/samsung/style-n-win-dev/insert-services2.php(54): FacebookRestClient->stream_publish(‘From My App: pu…’, NULL, NULL, ’100000845001406′, ’109444382410730′) #2 {main}
but if I use following code which person B comes and likes his own avatar it works and publish post on the wall without error.
$facebook->api_client->stream_publish($message,null,null,$personB_id,$app_id)
please can you guide me where i am doing mistake.
thanks a lot
Aarif, It could be the Permission issue from Step4, check once
hi sir..
i can’t download facebook library..
the link above gave me error not found ..
am i wrong?…
thx
ive download from http://github.com/facebook/php-sdk
but after run the code, i got this error,
Fatal error: Call to undefined method stdClass::admin_setAppProperties()
in my php code i’ve include
require_once ‘./facebook.php’; // it is the same path with my index.php
need a clue.
thx
Hi Dina,
Thanks for pointing that out, I have updated the link now. Facebook has changed that URL.
thx sir,
it’s works
Hi,
I run the test code and got the following error:
Fatal error: Call to undefined method Facebook::require_login() in /home/content/46/4899446/html/facebook/mytestapp/index.php on line 18
Any idea?
Steven does your library still works is everything ok? I performed all steps before and it worked but now i cant get to use the function from it. I have checked everything. When it comes for functions it stops.
Aziz,
Which function are u referring, Face book has changed some of the api settings.
I am using
$facebook->api_client->stream_publish();
$facebook->api_client->photos_upload();
$facebook->api_client->video_upload();
Aziz, Try download the library from above, facebook has changed its library. The methods you are using still work.
Hmm… when i used this tutorial from begining it worked fine again and I have checked all my previous codes, they worked too. strange.. though. Anyway thank you again and for the tutorial again. I just wonder if it is possible to do the same with new api
Hi Steven,
Thanx for such wonderful description, its pretty easy as we go step by step.
I was just wondering if my website can have ability to post on other user’s wall
thanx
Hi Nikhil, If the user gives permission to their wall then you can publish on their wall too.
Ya I understand that but don’t they require their API Key and all, an average user won’t even take little pain to get their Keys
What I need is that user could post on other person’s(friends ) wall.
Thanx for quick response
No Nikhil, Your API will be sufficient, They just need to give permission to their wall.
Hi i tried several times to do it but i get this error exception ‘FacebookRestClientException’ with message ‘Session key invalid or no longer valid etc..
Help!!
Hi Steven
Very nice post thanks man. I am facing one issue.
We can post the message to my Facebook wall, But the other user whole are using my app will cannot post message on their Facebook walls.
Help!!
Grace
can you give us the source code
require_login();
$fb = new FacebookRestClient(FB_APIKEY, FB_SECRET);
$facebook->api_client->session_key = $fb->do_get_session($fb->auth_createToken());
$fetch = array(‘friends’ =>array(‘pattern’ => ‘.*’,'query’ => “select uid2 from friend where uid1={$user}”));
echo $facebook->api_client->admin_setAppProperties(array(‘preload_fql’ => json_encode($fetch)));
/*if( $facebook->api_client->stream_publish($message))
echo “Added on FB Wall”;
} catch(Exception $e) {
echo $e . “”;*/
//}
//$message = ‘Check out this cute pic.’;
$attachment = array(
‘name’ => ‘i\’m bursting with joy’,
‘href’ => ‘http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/’,
‘caption’ => ‘{*actor*} rated the lolcat 5 stars’,
‘description’ => ‘a funny looking cat’,
‘properties’ => array(‘category’ => array(
‘text’ => ‘humor’,
‘href’ => ‘http://www.icanhascheezburger.com/category/humor’),
‘ratings’ => ’5 stars’),
‘media’ => array(array(‘type’ => ‘image’,
‘src’ => ‘http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg’,
‘href’ => ‘http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/’)),
‘latitude’ => ’41.4′, //Let’s add some custom metadata in the form of key/value pairs
‘longitude’ => ’2.19′);
$action_links = array(
array(‘text’ => ‘Recaption this’,
‘href’ => ‘http://mine.icanhascheezburger.com/default.aspx?tiid=1192742&recap=1#step2′));
$attachment = json_encode($attachment);
$action_links = json_encode($action_links);
if($facebook->api_client->stream_publish($message)){
echo “Added on FB Wall”;
}else{
echo “FB Wall failed”;
}
} catch(Exception $e){
echo $e . “”;
}
?>
Hi,
I am trying to develop a project using facebook -java-api.
Here I want to extract the face book data and store them in a data base using the facebook-java-api. But I am new for this field.
I connected to the facebook developers page and created a new application. Now I need to know how to get the face book data like friend list/ profile picture etc. and where to place these codes I’m going to write.
If you can help me it is really appreciated.
Thank you!
its great man thanx a lot/////////
i was working with facebook app development and searched a lot in developer wiki but couldn’t find that… great great post
hi steven
Its very nice post thanks, I am facing one issue.
At Step2: Generate One Time Token to generate Session key ::
We have many users in my site.so as per your coding how can we generate One time Token using php code for different logins.
Please help us !!!!!!!
I follow the steps until 5. i got one time token and session. Now I run in localhost, then it shows the error as below: post on wallexception ‘FacebookRestClientException’ with message ‘Session key invalid or no longer valid’ in /var/www/anulya/facebook-platform/php/facebookapi_php5_restlib.php:3025 Stack trace: #0 /var/www/anulya/facebook-platform/php/facebookapi_php5_restlib.php(2882): FacebookRestClient->call_method(‘facebook.admin….’, Array) #1 /var/www/anulya/facebook-platform/test.php(33): FacebookRestClient->admin_setAppProperties(Array) #2 {main}
Any help Please Thank you
Hi to all,
I have created th facebook application and i set the all permission for user to access. I want to get the session key for every user dynamically… by using this url http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY we cant get it dynamically… we can get by manually…. A thing is that, One user will come to my site, while he login i want to store all his information in DB with seesion key for offline access…. Another user ll.. as usually want to get… Please help to get it… very urgent…
I am starting the connection with this url http://m.facebook.com/authorize.php?api_key=YOUR_API_KEY&v=1.0&ext_perm=offline_access
if this url returns session key it ll be appreciated…
thanks
saran
http://careerjobz.com
Hi steven,
Thank you for your reply in few hours ago. Yet i still can find any solution for my problem.
When i open the page. It only echoed post on wall. No great wall appear. You may check it out here. http://h3llst0rm.phpnet.us/upd/haha.php
Hope you help me to sort this out. Thx
Hi Steven!
thank you very much for yours articles!
I would only know if it’s possible to add “Friend tags” or “Page tags” in stream_publish (using FBML libraries).
( Es.: “@[ID:4387]” -> “John” prefer pasta to pizza )
bye
Hi,
I don’t undersantd why, but Step 4 never show me 3 screens.
I only got “success” displayed.
You told :
‘If you don’t see the below then your call back URL or Canvas URL must be incorrect, please check again your application settings and execute the URL again.’
Can you give more explain please, my facebook application is running and everything seem good in definition of application.
Note: I want to post messages on my wall thrue application in batch mode, not in browser context.
Thanks for your reply
@piv64, you can do batch updates, the back URL or Canvas URL will be there in facebook setting page,
@Junior, you can add tags too
Hi,
In fact, even if nothing else than ‘success’ is displayed, configuration for write autorization on my facebook wall is good.
Important:
I saw a solution on application parameters in way to diagnose publish problems.
If application is defined as ‘desktop’, everything run and many obscured problem related to stream_publish are solved.
I think that lots of people are interested by this.
An other problem, is there a solution to send message with accent (french text) and what’s the solution for message encoding ?
Thank for your reply.
Hi Steven,
I thank you for the quick response!
I’m trying with this simple code but don’t work:
$message = ‘This message is sent by ‘;
The problem is that facebook does not view tags and show the string as it is…
see ‘ya
@Junior here is how you add tags to your post http://blog.theunical.com/facebook-integration/facebook-api-how-to-add-tags-to-post-api-using-php/
Hi Steven,
I tried but the script does not work as I want … maybe I have not explained well …
When I post a new message on my wall I would like the tagged user display a message in its notifications like “Junior have tagged you in a post.”
Currently, when I insert the tag as you suggested is not sent any notification to the recipient but only shows a link.
How can I do?
@Junior yes its just a link tag
please add a lesson for sending images to facebook wall in actual sizes
Thanks for the tut, i tried all the steps and it worked but i would like to use this link… https://graph.facebook.com/oauth/authorize?client_id=xxx&redirect_uri=http://apps.facebook.com/xxxx/&scope=publish_stream … in step 3.. i used the SESSIONKEY that was given to my profile and it worked… but how can i obtain the sessionkey that each user gets after granting the app permission? any way to grab theirs? i only want to post on their feeds/wall when they are online… i still don’t understand how to get each user’s sessionkey and send a post on each one of them. Thanks for any help
Hi Steven,
it’s possible to publish a message on the wall of the friends of the app/funpage?
Ex.:
1. User visit my site
2. The user publish a message on my site
3. My site publish this message on the facebook wall of the User
how do I write permissions?
Same question as Junior.
is there any script by which i can use user’s facebook login details, and can post something on user’s wall, as this can be done for twitter using cURL lib of php
thanks in advice ….
Hi,
I want to run a continuous fb wall posting from my cakephp code, Is there any way of doing the same, without generating this one time session key?
If yes, earliest reply would be appreciated!
JOI
@Joomla its mandate to generate the key
@Steven, thanks for your time and reply. Yes session key generation is must, but Is there a way; via my php script, it can generate automatic session and then post some message to users wall?
I am running another code, for twitter, into which tweeting message, which is working perfect as needed from our project source code, but for facebook I am not able to find much useful info, so would be appreciated, if you can help somehow to get facebook wall posting working from my website script dynamically/automatically !
Thanks in advance!
I’m getting the following error when trying to run the code. I actually tried combining the snippets into 1 page and this is what I got. Any ideas?
Fatal error: Uncaught exception ‘FacebookRestClientException’ with message ‘Invalid parameter’ in /home/webdad3/public_html/AlphaProject/library/facebook-platform/php/facebookapi_php5_restlib.php:3025 Stack trace: #0 /home/webdad3/public_html/AlphaProject/webservice/ws_facebookPublishing.php(14): FacebookRestClient->call_method(‘facebook.auth.g…’, Array) #1 {main} thrown in /home/webdad3/public_html/AlphaProject/library/facebook-platform/php/facebookapi_php5_restlib.php on line 3025
Ignore my comment. I got it to work. The tutorial does what it says it does
@ Jeff you can’t combine all the steps in one page, you need to do it seperatly
Ok… I followed the tutorial and it does what it says, but not what I thought it was going to do. Do you know how I can have the application post to its own wall?
For example if a user of the site does something, I want the site to post to the application wall so all that like the application will get that as part of the news feed.
I can’t seem to find this anywhere.
@ Jeff
hello Jeff, you can try to find something useful for you at below link:
http://wiki.developers.facebook.com/index.php/Stream.publish
They have specially mention “A developer of the application must edit the application profile page’s Wall Settings (Edit Application > Edit) and verify under Posting Ability that Fans can write or post content on the wall is checked.”, so I am thinking its for you, which you’re finding!
Cheers!
I am trying to make an application that allows users to select 4 different options from list that I will be providing them and I want to submit that to my wall. Can you help me set this up?
This is what I have so far
http://apps.facebook.com/activity_selection/
Thanks
Yaco
hi!
Steven Robert
First thanx for posting the good article …i also doing this but one problam come that when i give the url of canvas and connect after that click save button i found a error that your api key is invalid..what’s problam ..and i also want to know in canvas and connect url which links will be given..please help me….
thanks
hi!!
actually i working on the local copy for r&d and after this i will used on the originol sites.
thank
dinesh pal
@dinesh you can give any public URL unlike this local url like 192.168.0.9
hi Steven Robert
good morning
after complted the first step when i start step to and click the given url then i found a error like this(‘Invalid API key specified’.).what’s the mistake..please solve this problam..
thanks
for your help and support
hi
steven
where i copy the step 3 code….and how imlement this on your module…please give me responce..
thanks
@Dinesh for Step2 don’t run it directly on it just replace your APIkey and open it in browser. And for Step3 It will generate a unique session key just use it for Step5
thanks
Class ‘Facebook’ not found in /var/vhosts/apartmentsneakpeeks/httpdocs/facebook-platform/php/facebookapi_php5_restlib.php on line 82
Rest was fine but in the last due to session value is “” i could not make the post done.
Will you please mail me regarding this.
Thanks and Regards,
SHyam
Hi Steven,
can you assist me with an API for FB offline messages..am unable to do that..
The script you mentioned here is for the online messages not offline
Thanks in advance
everything is working nice, thanks for the script.
What about character encoding? Accent characters not shown. I do not find how to set char set
Hi Steven,
I need to post comment on my application users selecting from my data base but very confused in that. There are a number of ways given on the net apart from each other . I just setup tha application. Now want that the user who add the application his user id will be stored in my database and I can post some kind of rank for each users from my db
One strange problem i got is that.. when i first went on with the steps i got my postings to my wall. I tried it for another facebook profile and didnt succeed.Again i replaced the old code in my server and tried toxecute post to wall. now i am getting
Error
123exception ‘FacebookRestClientException’ with message ‘Session key invalid or no longer valid’ in /home/socialcr/public_html/beta/facebook/fb_app/facebook-platform/php/facebookapi_php5_restlib.php:3025 Stack trace: #0 /home/socialcr/public_html/beta/facebook/fb_app/facebook-platform/php/facebookapi_php5_restlib.php(2882): FacebookRestClient->call_method(‘facebook.admin….’, Array) #1 /home/socialcr/public_html/beta/facebook/fb_app/publish on wall.php(16): FacebookRestClient->admin_setAppProperties(Array) #2 {main}
Then with the above key execute the below URL in browser to give access to your program.
http://www.facebook.com/login.php?api_key=APIKEYXxxxxxxxxxxxxxxxxx&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&req_perms=read_stream,publish_stream,offline_access
Plz make me clear with this…..
Hi stephen… when i was posting $message value iam exactly getting the message displayed in facebook wall .
example :$message=”34% post opinions about products and brands on their blogs – Interested in profiting from social media? Try http://ow.ly/16C88 “;
It is posting well.
but when i tried to retrieve the same messages from my database like $message=mysql_fetch_row($tag_query); the message is displayed as
["34% post opinions about products and brands on their blogs - Interested in profiting from social media? Try http:\/\/ow.ly\/16C88\r"]
plz make me clear with this mate
Thanks in advance
I got this error….. Any help plz…..
post on wallexception ‘FacebookRestClientException’ with message ‘Invalid API key’ in /home/snauman/public_html/therunaround/facebook-client/php/facebookapi_php5_restlib.php:3025 Stack trace: #0 /home/snauman/public_html/therunaround/facebook-client/php/facebookapi_php5_restlib.php(2882): FacebookRestClient->call_method(‘facebook.admin….’, Array) #1 /home/snauman/public_html/therunaround/Udefinesuccess/index.php(27): FacebookRestClient->admin_setAppProperties(Array) #2 {main}
I would like to know if we can do both requesting permissions and executing our code in the same page,
because when i make the user type in the following url,
i cannot check whether he has successfully done it.
ne ideas will be greatly thankful
Hi!
Great post!
I would like to ask your help. I have multiple pages, created with open graph protocol, and I want to post on the page’s wall. The problem is, that the pages are created dynamic: when there is an event, I store it in a database, and I generate an open graph protocol page for the event.
How can I post to the page’s wall? I tried putting the page’s url as target_id, but no result; I tried your code, but I’m stuck at step 3 (104 Incorrect signature method facebook.auth.getSession session_key api_key [my_app_key] v 1.0); and a few other things, but no result. ![]()
Any help would be appreciated!
Hi All,
I’m new to developing for Facebook so sorry if my question is a stupid one!
I would like to set up the above example but I always get an error at Step 2.
The error is :
API Error Code: 100
API Error Description: Invalid parameter
Error Message: next is not owned by the application.
Anyone who can help me?
Thx,
Pieter
HI,
I keep on getting stuck in step #4,
I get the following message:
“To fix this error, please set your Connect URL in the application settings editor. Once it has been set, users will be redirected to that URL instead of this page after logging in.”
What can the problem be?
Please can anyone help – I’m stuck!!!!!
Hi,
Thanks for this lovely article. This article is very help full for me and i am able to post on user wall text as well as image but my problem in step 3 calling URL from browser its working but i want to fetch the user offline session-id from my web page using this URL how can i achieved this or any alternate way is there for getting user offline session-id?
Using java.
Please help me.
Thanks allot.
@Sumit using php you can check the above code , in java in need to verify the api
hey steven , nice article , but i a newbie with fb development. i want to create a poll application . i can handle the php stuff . but i want my application to post of on friends (of the current app user) wall. is that possible ? if yes can you direct me to the right direction.
and i have seen applications that do automatic posting on user’s friends walls at random , any tips or links on how that can be achieved.
your blog is awesome.
Thanks,
Furqan
Call to undefined method FacebookRestClient::stream_publish()
any clue whats wrong??
Hi Steven,
Thank you very much for reply,
But now i am able to fetch the user offline session id using FB JavaScript.
Thanks alot.
Regards
Sumit
thank you! it works
How make use of this code to bring permission in my application send me proper code
I am using php how to get onetime session using new php sdk pls help me
Hi ,Dude
1. Could you plz inform me where i have to use step 3 and 5.
2. where i have to use save my login info code.
3. finally , i got worked up with this code and the result is login page as well as request page i grant the permission “allow” after that this code is not responding itz still loading..
I did not see the Connect link in my application.
I only see About, Website, Facebook Integration, Mobile and devices, Advanced links.
Please help …
–
Baljeet
I have follow all the step of ur steps. But when i run ur code, it said Call to undefined method stdClass::admin_setAppProperties(). Can u help me pleas?
Hi Steven, Thanks a lot. I have been struggling to post to my fan page wall using php for last three weeks. Now I’m able to post to my own wall, and its a great step towards my goal.
actually I’m creating a free for all application where the people can publish messages, photos, videos, events to their pages.
Please guide me how to publish the message on fan page wall.
Thanks in advance
Baljeet
baljeets91@gmail.com
Hi Steve,
Hurray !!
I’m able to post to fan page now. I”ve one question which I’m posting on
http://blog.theunical.com/facebook-integration/publish-on-facebook-fan-page-as-fan-user-using-php/comment-page-1/#comment-9298
Is this method still working, or we must now use OAuth 2.0.
I am getting an error on step 2: “An error occurred. Please try again later.
”
Thanks
Hi Steven,
Thanks for your great tutorial!
Sorry to digress. But how do I allow users to register and login using their Facebook account? (the single sign-on) I cant seem to integrate Facebook with Webid for the login part. How do I authenticate users who have registered using their Facebook account to use my site & post the above news feed?
I’m using PHP, thanks! Hope to get a reply from you soon!
Edan, All the methods are working
I’m getting the same error as @185, Steven can you please confirm that this is actually working? I can’t see any way of getting around this.
Hi Happismile,
If you follow all the steps described here, there should be not problem.
In step 3, you will get permanent session key which will be used for logging in to facebook from your site. If your site has more than one users, then you can same their session keys in local database, that session key will be used for posting, or viewing the facebook data for that user.
Please let me know where you are facing the problem.
–
Baljeet
Hello Steven, Thanks for your help!
Today the facebook API on step 2 suddenly worked so every thing is ok.
I have a new question, I need to post a message to a Page I own (and not to my user), can you point me to the right direction?
Hi Balijeet
Thank you for your prompt response!
I’m using localhost as my testing server. So after I completed the 5 steps above, I’m the only Facebook user able to publish on Facebook wall.
I want to allow other Facebook users who use my site to also publish on Facebook wall. How do I get their session key using PHP for Step 2 & 3 and then save it to my database?
Thanks!
Happismiley
cbx006@gmail.com
Hi Happy, sorry for the late response due ti weekend.
If you ready the steps properly and know php, there should be no problme. Further, you can give my you email id, I’ll send the code I have done in php, with explanation.
Hi Balijeet
My email address is cbx006@gmail.com.
Anyway, does anybody know whether Facebook change their api again? I cant access my “Connect to Facebook” button since yesterday. ):
Thanks!
Happismiley
Hi Happy, You can find all the sample code here
http://www.fbsmm.com/2010/12/04/Simple-example-to-post-on-Facebook-wall-using-PHP
[...] Here is a wonderfull step-by-step manual how to do it “5 Steps to publish on a facebook wall using php“. [...]
hi i have understood and it works for me if i do manually setp 2 and 3.
i want my php script to perform step 2 and step 3 automatically when user login into my app. how can i do it?
Hi Gaurav,
2nd and 3rd steps can be merged and can be automate dusing php. You just need to call below url (make sure yiu replace value of next quesry string to the url where you want to redirect after success.):
If you are looking for ready-made php script for this go here
http://www.fbsmm.com/2010/12/04/simple-example-to-post-on-facebook-wall-using-php/
I have created this a sample script based on the steps discussed here by Steve.
great tutorial! … but I at step 2 I am getting the same error message as @185 and @188: “An error occurred. Please try again later.” tried different things but can’t get it work:( … not sure if I selected “Web” app correctly, the facebook interface for creating apps changed in the meantime. and re Canvas URL, can I type in any random URL or does it need to be a specific one? cheers!
I am able to send only plain text. When I send some HTML tags like <img… it does not work. Is there any solution to send to facebook wall HTML text too?
for showing images, you have to actually post an image to the wall.
Follow this
http://blog.theunical.com/facebook-integration/add-picture-on-facebook-wall-using-php/comment-page-1/
I am Stuck in Step 2
Generate One Time Token to generate Session key
I am Not able to get the token , an error occurred while clicking the link with my app key…
Raj Check if you created your Facebook app correctly.
FaceBook is deprecating some APIs from Jan 11, so please beware of when you create facebook apps
http://blog.theunical.com/facebook-integration/facebook-deprecating-some-apis-from-07-jan-11/
it seems that some people here are stuck at step 2. I had the same problem (see post 198), and did some further research. it turns out that there is a simple alternative solution with the Graph API- got it working with a 4 step procedure as described below.
It is still a manual solution though… I would be very interested in getting this automated. apparently one should use Graph API in future anyways, as some of the API functions used above might be deprecated soon. So a combination of the solution posted below and the php-solution to automatise this procedure as described in previous posts would be terrific… ideas anyone?
Here’s the how I did it with the Graph API:
1) Register a Facebook application and get App ID and App Secret http://developers.facebook.com/docs/guides/canvas
2) Ask the user for permission to publish posts on his wall
(see http://developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application)
- with client_id = your Facebook app ID, and is your and client_secret = your facebook application secret.
- use scope argument for extended permissions (i.e. offline_access, publish_stream), you need those in order to post messages on a user’s wall (http://developers.facebook.com/docs/authentication/#requesting-extended-permissions)
3) You will be redirected to the specified redirect_url. Copy verification string in the ‘code’ argument from the redirect URL, and paste it into this URL to get (permanent) Access Token:
4) Browser returns Access Token. Use Access Token and Graph API functions to post messages to user’s wall
…for further infos and examples see http://developers.facebook.com/docs/reference/api/post, e.g.
curl -F ‘access_token=ACCESS_TOKEN’ \
-F ‘message=Hello World. I like this new API.’ \
-F ‘link=http://www.example.com/article.html’ \
-F ‘picture=http://www.example.com/article-thumbnail.jpg’ \
-F ‘name=Article Title’ \
-F ‘caption=Caption for the link’ \
-F ‘description=Longer description of the link’ \
-F ‘actions={”name”: “View on Zombo”, “link”: “http://www.zombo.com”}’ \
-F ‘privacy={”value”: “ALL_FRIENDS”}’ \
-F ‘targeting= {”countries”:”US”,”regions”:”6,53″,”locales”:”6″}’ \
https://graph.facebook.com/FACEBOOK_USER_ID/feed
Hi,
This seems to be a good starting point. I was able to create an app and get my wordpress blog into facebook, but wanted to add functionality like updates to users on new post etc.
I am yet to try the steps provided, but from the detailed instructions I think it should not be such a difficult task.
Thank you for the wonderful tutorial.
Thanks a lot Steven, for your good tutorial for us.
I have a Quiz Application in the facebook Platform, I want to publish my quiz result in the news feed from a quiz application.The application is developed in IFRAME base.
Please give me code or instruction to me.
Please help me.
@Mbu The above same code works, while giving permission you just need to give for news feed too.
Thank you, thank you, thank you!
I have been searching the web for 3 days for this and nothing worked! Excellent tutorial!
[...] 5 Steps to publish on a facebook wall using php | TheUnical Technologies Blog (tags: tech development web social-networking) [...]
Hello steven,
First of all thanks a lot for a great article. I have one question If i want to post on my friends wall who is using this application. What modification i need to do in your script. So that i can post on my friends wall without login.
Thanks
Great post. Thank you for your contribution. Now we can finally post to our wall using php.
Dear
I have a Quiz Application in facebook platform and when I click the submit
button after correct the question then form data would not submit in the result
page using the Internet Explorer but in Firefox this is correct.
Also if I try secondly after first time in IE the result of a form data would
submit and result is come.
I was spent my huge time to correct this but i can’t do it.
What is the problem and which will be suggestion to me to solve this problem.
Please suggest me…
With regards
Nice post. This is how to post a message in your facebook wall, do you know how to post a link and change its description to facebook?
Hi Steven,
I have follow your guide, all sucess until step 5. I got only an echo “post on wall” print on screen and then blank page, and there was no post public on my facebook wall.
I see that you answer all the previous post, hopefully mine too. Thanks in advance.
Vicky
@Vicky Check the permissions again, or see if the page is authorized to publish the post.
@Madmax see my other post who to post images u will get it. Add Picture on facebook
I sent a message to the user’s wall, the operation was successful, but the message was in spam on the wall. Why?
Hi Steven, firstly thanks a lot for your tutorial. I have a question though: I followed your steps and was able to post to my facebook wall from my website. However even when someone else accesses my website it posts to my wall only. Not their wall. Am I missing something? Do we need to perform all the 5 steps with each user? Please guide me. I am very new to facebook API and I am probably doing something very foolish. Appreciate your help.
I am done with all the steps successfully…wow..great explanation..I am PHP developer but new to Facebook App….
I am done with Steps 1,2 and 4 ..yeah I got success page .. But I am unable to generate one time session key(Step 3) …I GET BLANK WHITE PAGE..no matter how many times I am trying(From past 1 day)..
What is the issue..please suggest….Thanks in advance
Hello All
How can we transform the update text to a update link ?
How use $action_links and $attachement with this code ?!
My code:
$page_id =”xxxxxxxxxxxxxxxxxxx”;
if( $facebook->api_client->stream_publish($message, $attachment,$action_links, null,$page_id))
Thanx a lot :’))
@Tokio Hotel see this post http://blog.theunical.com/facebook-integration/add-picture-on-facebook-wall-using-php/
Hi Steven, today I have an error on “Step2: Generate One Time Token to generate Session key”
I changed the “API_KEY” to mine from the link:
https://login.facebook.com/code_gen.php?api_key=API_KEY&v=1.0
But it gave me an error message of:
“An error occurred. Please try again later.” with “Okay” button underneath.
I clicked on that “Okay” button, but it gave me the same message.
What does it mean? And how to resolve this? Thank you.
PS:
Well, I got it work fine yesterday, until facebook thought there’s something ‘funny’ going on and got my facebook temporary ‘suspended’ (maybe because I kept on trying to post quite frequently using php? :p).
Then facebook asked to reset my password.
And it went back to normal again.
BUT, my apps GONE
Couldn’t be bothered to try it again last night, so I tried your 5 steps again today.
And everything works but not until I got to step 2.
Help please?
Thank you, Steven.
@lizzy, I seen that many FB users have similar problem, FB doesn’t work same for all users all the time, it will give some errors sometimes, keep try after some time.
[...] application page blog.theunical.com [...]
I am getting the following error in Step 3 (Generating the Permanent Session Key).
Fatal error: Class ‘FacebookRestClient’ not found in /home1/mermagic/public_html/test/session-key.php on line 7
Can someone please tell me where the Facebook php sdk should be located in order for the code to use it?
Hi Steven, i want to ask something, what is “{$user}” in step 5 line 23?
I still can not post something to my wall.. when i execute step 5 its just show “post on wall” on the browser.. no error message or “Added on FB Wall”
@ Joe Davila: FacebookRestClient class is on \facebook-platform\php\facebookapi_php5_restlib.php
Hello
When i go for step two i am getting error : An error occurred. Please try again later.
I am not able to move forward.
I have verified the API key which is correct then what would be the possible reason.
Please reply.
Thanks
Mukta
@Mukta It seems facebook has changed some settings, After you created your application try to given permissions step4 then try other steps.
Hello Stevan
Thanks for your reply.
As per your replay I given permissions to my application as mentioned in step4 but facing the same error.
Now what would be the possible reason?
You wrote :
# 24th Feb 2011 11:38 pm
@Mukta It seems facebook has changed some settings, After you created your application try to given permissions step4 then try other steps.
Thanks
Mukta
Hello Stevan
Suddenly step two error has stopeed coming and I have moved to step4.
But in step 4 I am getting following url and I am not able to complete all the steps.
http://www.facebook.com/developers/login_error.php?app_id=165631503489774&connect=1&type=connect
Please try to give me solution ASAP.
Thanks
Mukta
@Mukta For Step4 u need to use this URL to give permission
http://www.facebook.com/login.php?api_key=APIKEYXxxxxxxxxxxxxxxxxx&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&req_perms=read_stream,publish_stream,offline_access
replace APIKEY with your key
thanks i was looking for this code for posting a message on user’s wall , thanks again.
need help here. I can’t find CONNECT tab.
@fern, FB has changed its menu bars, soon I will update this post, mean while check for remaining menus
Hello Steven,
In step 4 if i m getting following url and I am not able to complete all the steps.
http://www.facebook.com/developers/login_error.php?app_id=138228446242989&connect=1&type=connect
@Steven Robert: please update this as soon as possible. tnx!
I’ll wait for the update.
hi, I would like to automaticly post on tmy application user’s wall when they use the application with a ,sentence, image back link, and connect link or something.
i have the permission set
can you help me please? and also how can i sometimes post on all user’s wall once in a while?
thank you
Hello All, I just updated the post will all latest screen shots and updated post content.
Every time when i post n this blog, the comment will not approve immediately, it takes time, but after taking time my comment was not appearing on the topics why is it so, is there any reason please mention,..
Hi,
I am done with posting my data on wall.I was facing problem with step 4 for permission. I have used the following url:
@Steven:Thanks a lot ur tutorial helped me a lot.
@khadija Did u replaced the MYAPPAPIKEy with your facebook app id?
@Steven:No, I replaced my app key with MYAPPAPIKEy.
@khadija use the same privilages http://www.facebook.com/login.php?api_key=APIKEYXxxxxxxxxxxxxxxxxx&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&req_perms=read_stream,publish_stream,offline_access
offline access/ read stream /publish
Hi Steven,
If i m using that url i m getting following error:
http://www.facebook.com/developers/login_error.php?app_id=138228446242989&connect=1&type=connect
Thanks,
khadija
Hello,
I have been trying to follow the steps in your description, but when I try to create an app I get the page “Your account must be verified before you can take this action. Please verify your account by adding your ….”
When I put the code specified on a page (internal), the link takes me to a credit card info page. Does this code need to go on a public page? Why does it take me to a payments page? To create an app is free, right?
Thanks
@Michael ,it is free, before that verify your phone number by entering the code that u will get from SMS.
Hi,
When we use https://login.facebook.com/code_gen.php?api_key=API_key&v=1.0
whith own api key . it gives error “An error occurred. Please try again later.”
I’m just new in your topic. But exactly, I always had a bad time I posting in the wall.
Your post could be my key to ease my problem. Thanks for sharing about it!
thank you for such a great, detailed tutorial — excellent!
Some of the Facebook code has changed since you posted this, and I was getting an assortment of error messages from functions that didn’t exist in the libraries I had. I finally got a clean version of matching libs at:
http://pearhub.org/get/facebook-0.1.0.tgz
Now everything works as you described… except I have one problem…
I need to post to an “organization” page but the comments are going to the regular user page (the administrator of the organization).
Is there any way to post to the wall of an organization/company/etc instead of posting to the wall of the user who is that org’s admin?
anybody?
Thanks!
@Pankaj, Many times FB gives same error try after sometime u will get it.
Hi Steven,
I have tried your code but i am getting error while creating the token id sir. The error is “An error occurred. Please try again later”. Please help me to sort out this issue sir.
Regards
Alan.
UPDATE – I figured it out!!
In order to post to a wall other than your own, you need to specify the target wall in the stream_publish transaction, like this…
$facebook->api_client->stream_publish($message,null,null,$TARGET_PAGE_ID,$TARGET_PAGE_ID);
…to publish to your own wall, use this shorter transaction…
$facebook->api_client->stream_publish($message)
…but if you really want to go all out and put pictures and links on a target wall, follow this formula…
$message = “This is the blurb at the very top of the post”;
$TEMP_IMAGE = “http://yourdomain.com/images/whatever.jpg”;
$TEMP_URL = “http://yourdomain.com/something.html”;
$TEMP_NAME = “Bold title to right of picture”;
$TEMP_CAPTION = “Detail paragraph below bold title “;
$attachment = array(
‘name’ => $TEMP_NAME,
‘href’ => $TEMP_URL,
‘caption’ => $TEMP_CAPTION,
‘description’ => ”,
‘media’ => array(array(
‘type’ => ‘image’,
‘src’ => $TEMP_IMAGE,
‘href’ => $TEMP_URL))
);
$action_links = array( array(‘text’ => $TEMP_NAME, ‘href’ => $TEMP_URL));
$facebook->api_client->stream_publish($message,$attachment,$action_links,$FB_PAGE_ID,$FB_PAGE_ID)
THANKS AGAIN TO EVERYONE !!!
Hi, i try this more than 3 times, but I still have a problem, i searching for solution, but I am not find it….
I try this step by step, then I try it with this:
Complet zip but still this error message:
http://blog.theunical.com/wp-content/uploads/2010/01/fb_app.zip
Fatal error: Class ‘Facebook’ not found in index.php
Thank you for answer
Majox
is it possible to add the PHP to a site that is using a localhost VIA wamp server?
Currently I am at the step to get my unique token, however it keeps erroring out and I am thinking that it might be as a result of entering in a address of http://localhost/insertwebsitehostedbywampserverhere anyways if someone knows if this is possible let me know.
Thanks,
Yes @Jeremy it is possible even with ur local host
Hi, please can you help me? I sucessfully upload files (from http://blog.theunical.com/wp-content/uploads/2010/01/fb_app.zip ) to my server, but I still have erro in index.php with this message “Fatal error: Class ‘Facebook’ ” thank you again for answer Majox.
Hi Steve, how are you?
I’m doing a project and facing this obstacle for many days now.
I have created a facebook app.
http://apps.facebook.com/myamazingidea/
The user can see his data after authorizing access to his account. How to i recognize who has authorized ?
Please let me know which connect url should I use, what it will return, how will I compare the return user id with the session for logged in user so that my system will not ask same user to authenticate again and it will show data for that particular user.
Hi, for two days I am trying to make this script… it\’s difficult, strnge thing… I got 1 post, but after it I got:
Fatal error: Uncaught exception \’FacebookRestClientException\’ with message \’Incorrect signature\’ in /home/psaddonc/public_html/facebook-platform/php/facebookapi_php5_restlib.php:3025 Stack trace: #0 /home/psaddonc/public_html/facebook-platform/php/facebookapi_php5_restlib.php(916): FacebookRestClient->call_method(\’facebook.stream…\’, Array) #1 /home/psaddonc/public_html/add_news.php(29): FacebookRestClient->stream_publish(\’news http://www…\’) #2 {main} thrown in /home/psaddonc/public_html/facebook-platform/php/facebookapi_php5_restlib.php on line 3025
don\’t understand why 1 message was posted and others no. Session key – can\’t get it, got a post without it, using this code:
require_once(\’facebook-platform/php/facebook.php\’);
$api_key = \”*–\”;
$secret_key = \”–\”;
$facebook = new Facebook ($api_key, $secret_key);
$user = $facebook->require_login();
$message = \’news http://www.mega.cl test\’;
$has_permission = $facebook-> api_client-> users_hasAppPermission (publish_stream);
//The user must give permission for your application publishes information on its wall.
if ($has_permission)
{
$facebook->api_client->stream_publish($message);
echo \”posted the message\”.$message.\”\”;
}
else{
$address = \”http://www.facebook.com/connect/prompt_permissions.php?api_key =\”. $api_key. \”& v = 1.0 & next = http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&display = popup & ext_perm = read_stream, publish_stream & enable_profile_selector = 1 & profile_selector_ids = \”. $user;
//header ( \”location: $address\”);
}
can you help me please?
Sorry my previous post did not sho up in the list. if you have received it please ignore this.
call_method(‘facebook.auth.getSession’,
array(‘auth_token’ => $testtoken, ‘generate_session_secret’ => true));
$facebook_infinite_session_key = $_SESSION['session_key']=$result['session_key'];
}
else
{
$facebook_infinite_session_key=$_SESSION['session_key'];
}
$facebook = new Facebook($FB_APIKEY, $FB_SECRET);
$infinite_key_array = $facebook->api_client->auth_getSession($auth_token);
print_r($infinite_key_array);
$facebook = new Facebook($FB_APIKEY, $FB_SECRET);
$infinite_key_array = $facebook->api_client->auth_getSession($auth_token);
print_r($infinite_key_array);
?>
1.This code did not printed anything. I think the session key is not generated. what’s wrong with this code?
2. If we use the other way to generate the session key.( i.e. to follow the url to generate permanent session. ) every user have to follow that url and generate session once. The target page is not our App’s page so we can’t keep the session key in that way. If there is a way please tell me. If we have to keep user id with session then we have know the user id to get the session key. to get user id we need api call which needs session key. Isn’t it a deadlock?
3. See, my intension is to create an app that simply when visited by user will prompt user for permission, if accepted automatically takes to a app’s page where he can publish a predefined (hard coded) message/caption, image, action links . Popups are hated.
Please help me doing this.
A super thanks in advance.
@SK Imdad Some times it gives error so try 4Step first then try to generate session key.
Good morning Steve, sorry to my english.
I can post status in the wall, but when use cron not work… Already try everything and cannot to use cron for automatize. Can be anything permission? if not use cron work!
My code:
api_client->session_key = FB_SESSION;
$fetch = array(‘friends’ =>
array(‘pattern’ => ‘.*’,
‘query’ => “select uid2 from friend where uid1={xxx}”));
echo $facebook->api_client->admin_setAppProperties(array(‘preload_fql’ => json_encode($fetch)));
$sql = $base ->query(‘SELECT * FROM wall WHERE DATE_FORMAT( data_agendada, “%H:%i” ) = DATE_FORMAT(“‘ . date(‘Y-m-d H:i:s’) . ‘”, “%H:%i”) ‘);
while ($result = $base ->tupla($sql)) {
echo $result ['text_facebook'].”";
echo “sign in”;
if ($facebook->api_client->stream_publish($resultado['text_faceboon].” Testing cron”))
echo “Added on test FB Wall”;
}
} catch (Exception $e) {
echo $e . “”;
}
?>
I’m trying to implement a code to post status on the facebook wall.
It’s working when I directly post the message. However, I would like to use “Cron” to schedule the posts and already tried everything without success.
Has anyone faced this problem? Can you help me with any tips?
Is there another solution without using “Cron”?
Thanks for your attention.
@Filipi Yes if you got permission the first time, then you can use it in cron.
SOLUTION TO: “An error occurred. Please try again later.” in Step-2
Hey everyone! – first of all, a HUGE thanks to Steven for opening Pandora’s box and letting all of us share his mad FB skilz
For everyone who encountered that annoying error in Step-2, there’s a quick and easy fix.
1) download this PHP source:
http://dl.dropbox.com/u/3681603/fb_kickstart.zip
it includes a folder called fb_kickstart
in it you’ll find: index.php (the kick starter)
and another sub folder called \src that contains the oAuth 2.0 version of facebook.php and the fb_ca_chain_bundle.crt file.
2) un-pack the contents to your desktop and then edit the index.php file changing the YOUR_APP_ID and YOUR_APP_SECRET values to the ones that go with your app.
3) push the folder over to your HTML root on the server and run:
http://YOURDOMAIN.COM/fb_kickstart/
You’ll get a screen that asks you allow your app access to your personal FB credentials — (USE THE FIRST BUTTON AT THE TOP) — say Yes to allow access.
Now, re-try Step-2 and it will work like a champ!
Thanks again Steven!!!
Hi,
I was wondering if you know a better way to revoke the extended permission (“publish_stream”). I am using Javascript SDK for publishing the post on Fb.
There is method for revoke in their legeacy api but I am not too keen on using that I was wondering if you have bettter soltn.
A great post it would have helped a lot of ppl.
Thanks,
H
what to do with step 5 code, where to execute?? also confirmed me i got the session key in { ……………. } i got the right?
How to programmatically the token? pls help
hello
after step one i got all keys and ids. but i c’nt generate token . means second step is creating problem.
Hi Steven,
I got the following problem. When i try to execute the generatesession.key.php or any other php file that you used.. i end up with a Blank page. I have tryed everything..
What could be the problem to this? Any ideas?
@Troy did u tried using FB library from this post?
Hi steven, thank for your link….
I have followed your code very smart.
My question is I’ve create a one facebook application.
But how to create code allow Link for other person, because my application not allow link applicable and not add friend application.
How to solve the issue.
and
$fetch = array(‘friends’ =>
array(‘pattern’ => ‘.*’,
How to change pattern or only one friend select and publish only one friend wall ?
Please check following link suggest me.
my application link : http://apps.facebook.com/autographbooks/
Thanks & Regards
Bharat.
Hi,
Its very useful blog for all. Can I use your java api with J2ME Polish or simple J2ME code ?
http://blog.theunical.com/facebook-integration/facebook-java-api-example-to-publish-on-wall/
Thanks,
Malay
@Malay you are always welcome
Keep in mind that “stream.publish” is not fully supported aymore, it´s now in “Legacy REST API” – so if you are building a new face-app you shouldn’t use this function. Use instead Graph API. Hope this helps somebody. Happy coding!
this is great! btw can i post a link that will automatically fetch the picture and the title like sharing a fb page?
first i have to thank Steven Robert. cox im using this method to update my fb page. now i want to ask that will this method (Stream Publish) works on posting into comments/replying or others profile or in other pages. i mean posting in others profile via my app?
yes @John , it works
Hii ! I want to create an app that shares on any user’s wall who accepts the permission dialog ! i did it well when it was with ‘FBML’ but i’m facing difficulties with ‘iframe’ ! This was my index.php when i was using FBML :
$app_id,
‘secret’ => $app_secret,
‘cookie’ => true,));
$session = $src->getSession();
$fbme = null;
if ($session) {
try {
$fbme = $src->api(‘/me?fields=id,first_name,last_name,email’);
} catch (FacebookApiException $e) {
error_log($e);
}
}
if (!$fbme) {
$login_url = $src->getLoginUrl(array(‘canvas’ => 1,
‘fbconnect’ => 0,
‘req_perms’ => ‘publish_stream’,
‘next’ => $app_canvas,
‘cancel_url’ => ‘http://apps.facebook.com/raycharles/’ ));
echo ”;
}
$user_id = $fbme[id];
$user_first_name = $fbme[first_name];
$token = $session[access_token];
$message = “”;
$link = “”;
$picture = “”;
$name = “”;
$caption = “$user_first_name a installé ce pack”;
$description = “incroyable !!”;
$post = “message=$message&access_token=$token&link=$link&picture=$picture&name=$name&caption=$caption&description=$description”;
$curl = curl_init(“https://graph.facebook.com/me/feed”);
curl_setopt($curl,CURLOPT_POST, true);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_exec($curl);
curl_close($curl);
?>
Just to give u an idea about what i’m talking about !
This code doesn’t work anymore ! Please help me ! how can i do the same thing with iframe ! thanks
I need to send my facebook users to my wall from my welcome page.
I have the code to determine if they are a fan. If they are not a fan, I ask
them to become a fan by liking me. Once they do, I want to direct them
to my wall automatically. What is the code to perform just this?
Seems simple but I can’t seem to find any examples.
Nice tutorial..
I have not tried the given scripts yet. Could you please tell what the following part does?
$fetch = array(‘friends’ =>
array(‘pattern’ => ‘.*’,
‘query’ => “select uid2 from friend where uid1={$user}”));
echo $facebook->api_client->admin_setAppProperties(array(‘preload_fql’ => json_encode($fetch)));
What I require is to make the user able to select one of his friends so I may get friend_id. I hope am clear. It d be great if you could help.
Thanks
I hav error.
Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/paghama/domains/alumni.comswu.com/public_html/tw.php:11) in /home/paghama/domains/alumni.comswu.com/public_html/facebook.php on line 37
Fatal error: Call to undefined method stdClass::admin_setAppProperties() in /home/paghama/domains/alumni.comswu.com/public_html/tw.php on line 25
Can u help me
To send users to another website or to an app on your facebook page, you can use the PHP code as described here:
http://php.about.com/od/learnphp/ht/phpredirection.htm.
Now on your facebook welcome page, once you determine they are a fan, use this code to send them to your app. However, I do not know the code how to send a user to the wall, just an app. That would be useful to know as well.
Were do i find the
YOUR_SESSION_key
define(‘FB_SESSION’, ‘YOUR_SESSION_key’);
I cant fin it
followed the steps and it works. thanks
Please anyone here can give an idea on how can I generate the TOKEN ID and SESSION KEY dynamically without typing the URL?
I dont understand on steps 3
After i make a php script on step 3.
Then, what must i do with this script ?
Save ? other name xxxx.php ?
Yes you can save that to a .php file
steven , if i put my URL in my app as “http://127.0.0.1/index.php” , can it work? because my website is localhost
@arron, Its better if you host on a public domain , not localhost.
HI Steven ,
I have created a new application on FB.I can access it from new Tab ,but my friends or anyone on FB cannot access it…They cannot get it.I have to publish or submit my newly created Apps?
@sanjay Your friends should be able to see it , did u changed any settings on ur FB? To publish on their walls they need to give permission.
Hi steven
I want to post on facebook wall from my website i have also code which i have downloaded from http://blog.theunical.com/wp-content/uploads/2010/01/fb_app.zip
but after applying
facebook_api_key, facebook_api_secret and testtoken as access token i am still getting the following errors
Fatal error: Uncaught exception ‘FacebookRestClientException’ with message ‘The parameter auth_token is required’ in E:\DEV4.HCS\testingcode\facebook_wall\facebook-platform\php\facebookapi_php5_restlib.php:3025 Stack trace: #0 E:\DEV4.HCS\testingcode\facebook_wall\facebook-platform\php\facebookapi_php5_restlib.php(300): FacebookRestClient->call_method(‘facebook.auth.g…’, Array) #1 E:\DEV4.HCS\testingcode\facebook_wall\index.php(6): FacebookRestClient->auth_getSession(NULL) #2 {main} thrown in E:\DEV4.HCS\testingcode\facebook_wall\facebook-platform\php\facebookapi_php5_restlib.php on line 3025
can i have solution for this
thank you very much for providing such helping platform.
thanks again
mit
@Mit are u trying from ur local machine? Try from a public IP
Hi Steven,
Thanks for such a great post. We are also doing the same task for one of our website. We are able to fetch the User details as well as User’s Friend List. User’s friend list means the details of friends and relatives, whom user has added in his Facebook account.
But we are facing problems In:
1. Getting the email Id and Mobile number of User’s Friend.
2. Posting a dynamic message on the wall of multiple friend’s (User’s Friend). We do not have the email id of the friends but we have a unique Facebook id of all these friends of the user. We want to post a message on friend’s wall using the same id.
The functionality is like given below:
User will login to our website and will select multiple friends/relatives from his friend list that we had fetched from Facebook. Then he will write a message for all his selected friends.
When he will click on submit button, we want to post a message like, has sent a message to to invite him to meet at . Please click the link to view more details about the user.
This message should post on the wall of all the selected friends. We have and stored in database.
Hi Steven
Mit Here again
i have to make post on my Facebook profile from my website and some how managed to make post getting login in to face book but now i am facing problem is that if logout from Facebook my website login page cannot maintain my session .once i am logout it gives me message
stdClass Object ( [error] => stdClass Object ( [message] => Error validating access token: Session has expired at unix time 1323518400. The current unix time is 1323519398. [type] => OAuthException ) )
even if again login from direclty from faceboo it shows me i am already logout
Here is the path
http://clients.teamevolution.com.au/bym/mithun_facebook/index.php
we can also post a message from
after login
here is the code
===============================
$_SESSION['accesstoken'], ‘message’=>$_REQUEST['txt'] );
$url = ‘https://graph.facebook.com/’.$currentuser->facebookid.’/feed’;
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_POSTFIELDS => $params,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_VERBOSE => true
));
$result = curl_exec($ch);
curl_close($ch);
echo ‘Post successfully in Facebook.’;
}
$curl = curl_init(‘https://graph.facebook.com/me?fields=id,name,bio&access_token=’.$_SESSION['accesstoken']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
$fbuid = json_decode($result);
print_r($fbuid);
$user_id=$fbuid->id;
if(is_null($user_id))
{$_SESSION['live']=”No”;}
else
{$_SESSION['live']=”YES”;}
echo ‘Your name:‘.$fbuid->name.’‘;
echo ‘About you:‘.$fbuid->bio.’‘;
echo ‘Ur Profile link:id.’” target=”_blank”>Click here‘;
echo ‘Write something to post it in your Facebook wall’;
echo ”;
echo ”;
echo ”;
echo ”;
echo ‘Submit’;
echo ”;
echo ”;
}
elseif($_REQUEST['code'])
{
//getting access token from the retrieved code.
// change $returnurl in the next line
$returnurl = “http://clients.teamevolution.com.au/bym/mithun_facebook/index.php”;
$url = ‘https://graph.facebook.com/oauth/access_token?client_id=’.$appid.’&redirect_uri=’.$returnurl.’&client_secret=’.$key.’&code=’.$_REQUEST['code'];
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_VERBOSE => true
));
$result = curl_exec($ch);
curl_close($ch);
$accesstoken = explode(‘&’, $result);
$accesstoken = explode(‘=’, $accesstoken['0']);
//setting the accesstoken in a session to use it later.
$_SESSION['accesstoken'] = $accesstoken = $accesstoken['1'];
//following script to refresh the page after session is set
echo ‘window.location.reload();’;
}
else
{
$returnurl = “http://clients.teamevolution.com.au/bym/mithun_facebook/index.php”;
$url = “https://graph.facebook.com/oauth/authorize?”;
$url .= “client_id=”.$appid.”&”;
$url .= “redirect_uri=”.$returnurl.”&”;
$url .= “scope=publish_stream,email,user_about_me”;
$url .= “&display=popup”;
echo ‘Connect to Facebook‘;
}
?>
Hi Stevan,
I tried your code and it worked for me but i have few problem regarding posting. Actually, Whenever I try to logged in with different users, the wallpost goes with same name off APPS admin. [Nischal Tiwari] like that.
I have a login/logout feature that means who ever sign in, i want to see their name in the wallpost instead of Apps admin. Is that possible ?
Let me know
Hi Steven,
I done these 5 steps and it is working perfectly into the profile wall. But i want it post to page wall. i have seen that you mentioned regarding target id. I am not able to find where i can do that. I am looking forward to your reply.
Thanks
Hi,
I am creating a ASP.NET application and i want to do same thing for ASP.NET, here the Example is explained in PHP. SO can you help me how to implement in ASP.NET(In Both C#,VB).
Thanks
Sanjay Soral
First, thank you so much. I’ve been searching and banging my head against the wall for days trying to get this kind of thing to work.
I did exactly what you said and it worked like a charm.
Now to implement it on my site. I’m going to post the idea here in case you can help figure it out before I get to it later.
I’m using the facebook registration plugin for registration, then saving their fb id in a database. Then I have a database of quotes and I want to be able to have them click “share” and have it post to their wall. They have to be logged on to fb and registered with the site in order to even see the quotes.
What I have to figure out is what to do with the Step 2 and 3 stuff there. Does each user have to physically copy the code from step 2, or can I access it another way? Do I need to get the session key for each user in Step 3 only once, then save it in my database to use when that particular user shares?
Off to play. I’m just thrilled you’ve given me a starting point. When I know it “CAN” work, I’m much better at finding out how to make it work.
Hi Steven,
I did the all steps. But I don’t know how to run the php code or what should I use to run the php code. Could you teach me? Thank you so much.
Hello…i am following your 5 steps and built up a application and its going perfectly but after 2-3 months a checked then i got a error that your session was expired ot too old ,so for this i create new Token and Session…..can any one give me solution for that???I have to use that session all the time because i created dynamic application and i can’t create session each time.
Please reply ASAP
Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!















