facebook auto post using php

facebook page post from PHP

How to autopost to facebook page using php

Facebook auto post using php, hmm.., I have a post on this topic a while ago, this one.

This post answers your questions of how to post to facebook page using php.

Though some of the initial steps do still hold, that is no more the case today. In order to combat the fake news and other improper usage of the platform, facebook has come up with different approach.
Continue reading facebook page post from PHP

facebook logo

Facebook Link Ownership in Facebook posts

Facebook link ownership when posting links from using facebook app

Facebook link ownership is hot issue now. Facebook is getting smarter and stricter from time to time.

In good days, all you have to do was to post the link to the page automatically using the app and get the traffic.

Now, when you try to do that, Facebook requires you to verify your ownership of the website you are posting a link to.

Part of it was done through the Open Graph tags. But now, it requires a bit more than that.

How to set a link ownership of the website for facebook posts

Before we dive into the how, you need to make sure you qualify the following points.

1. The first thing is, you need to have access to the website you are trying to post links from facebook app yourself.

2. You are an admin of the facebook page you are trying to post.

3. It is assumed you already have facebook app you want you use for posting to facebook page.

Now here are the steps:

1. Go to business.facebook.com

2. Click the business setting, you will find it on the right top corner.

3. On the left, under the account menu select pages and click on the add to add the page.

4. Select “Add Page” and follow the wizard to add the page.

5. Once you are done adding the page, on the left menu under brand safety, click on domains.

6. Here add click on “Add” to add the the website. You need to have access to the server of the website as it gives you file to put there.

7. Once you are done with number 6 and do the verification, go back to domains and select the website you verified.

8. Here you see options to assign pages. When you click on “Assign Pages” you get the list of pages you added on the previous steps. Now you can associate the page to the website.

Congratulations! Now when you are using your Facebook app to post articles or anything from your website to your Facebook page, Facebook knows you owned it and will allow you to post.

Good luck.

facebook social marketing

Add batch/multiple posts to Facebook Page – Graph API

facebook graph API batch request usage

If you have or managing any facebook page, chances are you might be using faebook’s graph API. It comes with lots of flavors of languages like Java, PHP, Javascript.

Ok you know about that, this post is not about that. If you want to see how to make a post to facebook through graph API, look at this post https://gullele.com/using-facebook-api-post-articles-php/

This post is about making multiple posts to Facebook page.

Why would I need batch requests

Imagine you have 20 blog articles you want to post to facebook. If you are not using batch, then it means you are sending 20 post requests to facebook. And as you can imaging it is easy to hit the limit easily. Facebook will stop you from bombarding their site.

When you are using batch, you have only one request, holding all 20 posts. Yup, that is it. One request vs 20. Now you know why you have to use that.

How to send multiple blog posts or other posts to Facebook page at once

If you follow the above link I referenced, you will have an idea on how single post is doing. I will just continue on that example class and will add just one more method to handle batch request.

The main idea is, each blog or whatever post has to be an object of Request. And you will send all those requests wrapped in one and send it.


	/**
	 * Send batch request to FB than a single one
	 * @param $post_data
	 */
	private function batchPost(array $post_data, $token)
	{
		/*
		 * In the case of the batch request, each has to be an object of request. And all those can be 
		 * send as one big request.
		 */
		$batch_response = [];
		$requests = [];
		foreach ($post_data as $id => $data) {
			$requests[$id] = $this->facebook->request('POST', '/me/feed', $data);
		}

		$batch_response = $this->facebook->sendBatchRequest($requests, $token);

		return $batch_response;
	}

In the above example, the method will be accepting $post_data as a parameter. If a post example is considered, a single $data will look like


$data = [
			'link' => "https://gullele.com/link-goes-here",
			'message'=>"how to make batch request in facebook api",
			'title'=>"Making Multiple Requests in Facebook",
			'description' => 'In this article I will show you how you can make multiple blog posts to Facebook page with one single request.',
		];

Then the line with $this->facebook->request will create a request object and add it as part of request array. Also mind the $id, each should have unique key in the $request array.

Then Facebook will send you back the response with post id and other lots of information that you might want to keep it for later reference like to get metrics on the post – how many likes, impressions, shares.. which will help you to improve in the long run.

Let me know if you have any questions or other methods.

Using Facebook API to post articles from PHP

How to automatically post to facebook page using PHP

This one is a bit detailed tutorial that is assumed for a novice php programmer who is new to Facebook API

Step 1.
Create a developer account from developer.facebook.com. All you need is your facebook account and you can get a developer account from it.

Step 2.
Create a Facebook page. From your Facebook page, on the top right corner, click on the dropdown menu and hit on create page. Select the type of the page you would like to create and then you have it.

Now what you want to do is, to create an auto post to the facebook page you just created from PHP. Lets say you run a blog or product page and you want to post whenever there is new stuff to be posted to the facebook page automatically.
Continue reading Using Facebook API to post articles from PHP

facebook social marketing

Post to Facebook From app – Using PHP

Post to Facebook programatically

You can post whatever you like from PHP to your or company’s page. Facebook has provided an SDK that makes life easier to post to the Facebook page.

This is ideal if you want to post to facebook, from cron job especially. Or on some event like right after the post in wordpress.

First thing first, you need to have a developer account on Facebook and you can do that easily and free on https://developers.facebook.com

Then you need to create an app. A single page or something like that would work. You will see how to create one when you are setting up your account for developer.

Once you have that, on the left menu, you will see dashboard. This contains important information about the app you will use to interact from your code.
Continue reading Post to Facebook From app – Using PHP

facebook social marketing

Hooking Facebook App to Existing FB Business Manager

Working on Facebook marketing reporting which require setting up a Facebook App and hooking it to existing Business manager and it looks there is no direct instruction that I found so here you go…

First thing first, you would need a developer account from https://developers.facebook.com/ – go and get it, it is free.

Then Go ahead and create a Facebook App there – a minimum you need is a facebook page and thats it.
Then from the dashboard you will get the app_id and secret. This is very important for you to keep it as secret as well. From this, you will get yet another important key called Access Token.

Now you have a Facebook App that you will use it to acquire a lot of information for the business manager you have. You can get lots of User related data, analytics, sales, spending and more..

Now head to https://business.facebook.com/ and select your business manager if you have more than one.
On the left of the menu, you will see Claim Assets and from there select App
You will be asked to insert App Id and it will be a matter of following the instruction after that.
Now you have integrated your app to the existing business manager. Which means, your app now has an access to the data under your business manager through different APIs.

EnJoy