Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Resolved Question

How do I post to Facebook from my website?

Jan 12, 2014 3:14PM PST

I wrote a PHP program for blogging. I'd like to add the option of duplicating my post on Facebook. I know this is possible because the comment feature at nfl.com has this feature. To see what I'm talking about, go to http://www.nfl.com/gamecenter/2014011900/2013/POST20/patriots@broncos#menu=gameinfo&tab=preview, there is a checkbox with the text "Also post on facebook".

I found a lot of information on this, but it was all bad. I even wasted a couple hours on tutorial that didn't work. Does anyone tell me how to do this or point me to an easy to understand tutorial that actually works?

Thanks in advance.

Discussion is locked

rondvorak has chosen the best answer to their question. View answer
- Collapse -
Clarification Request
Do you want to...
Jan 13, 2014 4:48AM PST

a) Share your post on your Facebook page?
b) Share your post on a user's Facebook page?
c) Share a user's comment on your Facebook page?
d) Share a user's comment on their Facebook page?

All that said, you can have the exact functionality NFL.com has by using Facebook's commenting system: https://developers.facebook.com/docs/plugins/comments

~Sovereign

- Collapse -
clarification
Jan 13, 2014 12:21PM PST

I'm sorry, I didn't do a very good job of explaining what I want to do. I don't want a comments section, I want to duplicate a post on my blog as a Facebook post. Here's how I want it to work.

1. I login to my blog(PHP code I wrote without a tool)
2. I edit a particular post.
3. A textarea is displayed containing the text for the blog entry and there is a "Post to Facebook" button.
4. Clicking on the a "Post to Facebook" button will cause the text within the textarea to be posted to my Facebook page.

I used the nfl.com example just to show that it is possible(or at least should be possible) to make a Facebook post from a web page. I see now how that was confusing.

I tried unsuccessfully to accomplish my goal by using the send button plugin(https://developers.facebook.com/docs/plugins/send-button). My plan was to hide the Facebook send button then clicking my "Post to Facebook" would cause the form associated with Facebook send button to be filled and submitted.

One of the tutorials I mentioned in my original post has a flow chart that does a good job explaining what I want to do, but the details of the solution are confusing and I just couldn't get it to work. Here is the link - http://www.barattalo.it/2010/01/17/posting-to-facebook-from-website-with-facebook-connect.

Anyway, any insights would be appreciated.

Thank you.

- Collapse -
Thanks for the clarification
Jan 14, 2014 2:08AM PST

To confirm, you want the entire blog post on your Facebook wall upon submission? I ask, because generally you want to direct traffic to your site and only tease the content on Facebook, but it sounds like you're not looking to do that.

We're basically talking about sharing your post vs. using the Facebook API to post something as if you had logged in and manually posted it on your wall.

~Sovereign

Best Answer

- Collapse -
Solved
Jan 14, 2014 1:13PM PST

I found an example on the Facebook site that I can use to solve my problem. For the benefit of others that might want to do the same thing, I'll explain what I did. First I got the example included with the PHP SDK to work, then I added an example that posts a message to Facebook to the SDK example folder. Perhaps someone looking to drive traffic to their site can expand upon my instructions and create a quality tutorial. Here are the details:


Example from the SDK(simple connect)
=============================
1. Download the zip file with the PHP SDK, including the examples
- https://github.com/facebook/facebook-php-sdk
2. Go to https://developers.facebook.com/
3. Select "Apps | Create a New App" from the top menu
4. Enter a Display Name and select a category(I chose "Apps for Pages" but I don't know if it matters).
5. Click create App and get click through the captch form.
6. Click settings on the left side menu
7. Click "+ Add Platform" and select "Website"
8. For the "Site URL", enter the of for the folder containing the example
9. Get the App ID and App Secret at the top portion of the page and enter it into the example program.
10. Test the example to make sure it works

Example that posts a message(and link) to Facebook
=======================================
1. Go to https://developers.facebook.com/docs/php/howto/postwithgraphapi
2. Create post_links.php(call it whatever you want) in the same directory as example.php
3. Enter the App ID and App Secret(same as for example.php) into post_links.php
4. In example.php, change require_once('../src/facebook.php'); to require_once('php-sdk/facebook.php');
5. Upload and test

Thank you Sovereign for your help, much appreciated.