Not Making Money With Classic Funnels?

Take my 10-day course for FREE

(value: $99)


"

Recurring Profits

Every Month"

Yes, I Want It

Nope

How to make your own Facebook Autoposter that creates posts with PHP



avatar
Written by Gene Adam
3,154 views

Hey, guys!

 

Today I want to go over how to auto-post your content from PHP to your own Facebook timeline.

 

I've planned a project for my blog for a while now... and I wanted to program an auto poster that could post simultaneously to:

 

  • my blog
  • facebook
  • twitter
  • instagram
  • etc... 

 

But for the sake of this article, I will cover only the Facebook auto poster.

 

THE GOAL: I want to click a button and make my content appear on my Facebook timeline.

 

Let's say I want to upload a photo to Facebook.

 

Here's an example PHP code for auto posting an image to Facebook:

 

fbpost.php

 

 

Download this PHP file here.

 

Note: You have to have {app-id}, {app-secret} and {access-token} filled out... I'll walk you through how to get it below...

 

Also, make sure you have the right path to your image...

 

Before you can run this code you need a few things first.

 

Things you will need:

 

  1. You'll need a PHP SDK to communicate with Facebook API.
    Download Facebook PHP SDK  from Github at You may use any library available (in PHP section) of https://github.com/facebook/php-graph-sdk
    (It's like a PHP module to help you make it work.)
  2. You need to create a Facebook App:  https://developers.facebook.com/apps
  3. You need to know that there are "Facebook Access Tokens" and they expire in 60 days. It's kinda like cookies but Facebook gives it to you to make sure "you" are the real you.. kinda a security "thang". No worries it's easy to get 'em.

 

Ok, now you know what we need let's go step by step.

 

STEP 1: DOWNLOAD PHP SDK

 

Go to the link: https://github.com/facebook/php-graph-sdk  and download. Put the files on your server.

 

STEP 2: CREATE FACEBOOK APP

 

Go to: https://developers.facebook.com/apps and create a Facebook app...

 

In my case, I created a "test" app first. So I could test it while I'm programming.

 

It'll look like this:
 

 

Name it and Create App Id.

 

After you fill everything out, you will get to a screen like this:

 

 

Next, Click on Choose Platform.

 

And choose: "Website (www)"

 

Now you have the {app_id} and {app_secret}. Take those variables and put them in the code above...

 

STEP 3: GET A FACEBOOK TOKEN

 

Great! We are getting there...

The last thing we need to get is the facebook {access-token}.

 

This is how we do it.

 

We need to run a code on your server.
 

fbtoken.php

 

 

Download this PHP file here.

 

 

There's another way to get this string if you don't prefer using fbtoken.php...

 

 

STEP 4: INPUT ALL OF THE VARIABLE in the fbpost.php
 
You have the {app_id} and {app_secret} from step 2.
 
And now when you run the fbtoken.php you need to login into Facebook and then you will get a long string... 
 
Take that long string and copy and paste into fbpost.php under $accessToken.
 
Now you are ready to post. BOOM!

 

When you execute your PHP it will post to your FB timeline.

 

DONE!

 

Go to your Facebook page.

The image should be there...
 
Hope this helps... Enjoy!
 

 

Sincerely,     

     


You passive income guy     



Similar Articles



Categories





Fill out the form below to get exclusive access.

Get Instant Access...

Your information is never shared.

Load 10 More...