Facebook page post with api php - IT NEWS

Latest

Programming PHP tutorials for beginners. Technology and product reviews.

Tuesday, May 9, 2017

Facebook page post with api php

Adv
Facebook Page api

Facebook page post api php

With Facebook Graph API explorer you can make auto post to your FB page. Here you will find free simple curl request with data to Facebook API.
Facebook page post with api php script:

$access_token = "********"; //Facebook Page Access Token
$page_id = "*************"; //Facebook Page ID

$url = "https://graph.facebook.com/$page_id/feed";

$data = array(
'access_token' => $access_token,
'message' => "Text2",
'link' => "www.google.fi",
'name' => "my name", // Title for link
'description' => "description" // Description for link
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);
print_r ($result);

Facebook page auto post

After this Post request you will receive your post message ID
Facebook Page api

With this PHP example you can send: Message, Link with custom Name and Description.

How to get Facebook Page id?

Enter your Facebook page URL here:
https://findmyfbid.com
and you will get Facebook Page ID number

How to get Facebook Page Access Token?

Page access token is NOT your app access token. When you are using wrong token you will receive from Facebook: "200 The user hasn't authorized the application to perform this action".
How to generate Page Access Token?

1. https://developers.facebook.com/tools-and-support/ -> Graph API Explorer
Facebook Page Access Token
2. Press Get User Access Token and generate new
Facebook Page Access Token
3.Select manage_pages and publish_pages:
Facebook Page Access Token
Click get access token, then continue
Facebook Page Access Token

4. Click on page title from list to generate new Facebook Page Access Token


5. This is your temporal Facebook Page Access Token for 2 hours.
Facebook Page Access Token


https://www.facebook.com/chakabiz
https://www.youtube.com/channel/UCYuMRNb_SRZ4FMsZjnHRZUA

No comments:

Post a Comment