Automatically Post On Facebook Using PHP with Graph API

Automatically Post On Facebook Using PHP with Graph API

In this Post We Will Explain About is Automatically Post On Facebook Using PHP with Graph API With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to facebook auto post script Example

In this post we will show you Best way to implement auto post to facebook from website, hear for how to post on facebook wall using graph api with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

How to Auto Post on Facebook Using PHP

In this POST we Shall show you how to post step by step automatically on Social marketing like as a Facebook using PHP and Social marketing like as a Facebook Graph API.You just have to make a Social marketing like as a Facebook App and get your Access Token and need a Social marketing like as a Facebook PHP SDK to help to post on Facebook.You can also like login with facebook using PHP.

To Post On Social marketing like as a Facebook Automatically It Takes Only Three Steps:-

1.Make A Facebook App
2.Get the simple Facebook Access Token
3.create a PHP file and init methods to Post On Facebook

Step 1.make A Facebook App

Second one creating Social marketing like as a Facebook web-App you need to download here libs like as a Facebook Download PHP SDK and then it requires PHP version 5.2.0 or simple higher for PHP data call to the curl extension.and then we have to create Social marketing like as a Facebook web-App go to step by step https://developers.facebook.com/apps and then following some the instructions step by step.

  Auto Post On Blogspot Using PHP script

Step 2.Get Social marketing like as a Facebook Access Token

To get a simple Access Token you have to set some developers accounts callback URL for the some Social marketing like as a Facebook app to get the appropriate result.And then authorize the web-app for some permissions on https://developers.facebook.com/docs/facebook-login/permissions/v2.2 as well as then get some the Access your web-Token.create sure simple renew your Facebook Token Afterall the expires 60 days because Social marketing like as a Facebook Access token will expires in about 60 days.

Step 3.Make a simple PHP file and define some methods to Post On FB MEans Facebook

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

We make a simple PHP file and root directory save it with a name Like as a autopost.php

<?php
require_once("FacebookSDK/facebook.php");
class FacebookApi 
{
//Devloped by Pakainfo.com init all the php var	
 var $consumer;
 /* Live token*/
 var $token;
 var $method;
 /* Live status know*/
 var $http_status;
 var $last_api_call;
 /* Live callback*/
 var $callback;
 var $connection;
 var $access_token;
 //Devloped by Pakainfo.com
 function __construct($data)
 {
  $config = array();
  $config['appId'] = $data['consumer_key'];
  $config['secret'] = $data['consumer_secret'];
 
  $this->connection = new Facebook($config);
 
 }
 //Devloped by Pakainfo.com
 function share($post_title, $post_URL, $share_IMGURL, $psot_desc, $access_token)
 {
  $this->connection->setAccessToken($access_token);
  $live_data["access_token"] = $access_token;
  
  if(!empty($post_title))
  {
   $live_data["message"] = $post_title;
   $live_data["name"] = $post_title;
  }
  //Devloped by Pakainfo.com
  if(!empty($post_URL))
  {
   $live_data["link"] = $post_URL;
  }
  //Devloped by Pakainfo.com
  if(!empty($share_IMGURL))
  {
   $live_data["picture"] = $share_IMGURL;
  }
  //Devloped by Pakainfo.com
  if(!empty($psot_desc))
  {
   $live_data["psot_desc"] = $psot_desc;
  }
 
  //Devloped by Pakainfo.com post to Facebook
  try 
  {
   $ret = $this->connection->api('/me/feed', 'POST', $live_data);
  }
  catch(Exception $e) 
  {
   $e->getMessage();
  }
 
  return true;
 }
 
 function getLoginUrl($live_data)
 {
  return $this->connection->getLoginUrl($live_data);
 }
 
 function getContent($url) 
 {
  $mylive_curl = curl_init();
  /*Live  Curl settings */
  curl_setopt($mylive_curl, CURLOPT_URL, $url);
  curl_setopt($mylive_curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($mylive_curl, CURLOPT_HEADER, false);
  curl_setopt( $mylive_curl, CURLOPT_CONNECTTIMEOUT, 10 );
  curl_setopt($mylive_curl, CURLOPT_SSL_VERIFYPEER, false);
 
  $response = curl_exec($mylive_curl);
  curl_close ($mylive_curl);
  return $response;
 }
 
}
?>

<?php
$access_token = "LIVE YOUR ACCESS TOKEN";
$facebookData = array();
$facebookData['consumer_key'] = "Put_YOUR_KEY";
$facebookData['consumer_secret'] = Put_YOUR_SECREATE_KEY;
 
$post_title = "Auto Post On Facebook Using PHP";
$post_URL = "https://www.pakainfo.com/";
$share_IMGURL = "https://www.pakainfo.com/live.jpg";
$psot_desc = "We are Web Technology Experts and Team who provide you very Important information on Web Development information,Examples and Demo, Interview Questions and Answers, live project problem solution and their solution and online free tutorials – Pakainfo.com."; 
 
$facebook = new FacebookApi($facebookData);
$facebook->share($post_title, $post_URL, $share_IMGURL, $psot_desc, $access_token);
?>

And then using above source code you post will be some set your corn job posted automatically on your Social marketing like as a Facebook profile automatically share.You can also like all the get Social marketing like as a facebook like all, share total and get the comment using PHP.

  Auto Post on Facebook page with php using Graph Api

Finaaly, this is how to your Post On Social marketing like as a Facebook Automatically sharing using PHP.we can customize this simple php souce code further as per your needed requirement. And please share my post feel free to share give the comments on this POST.

Example

I hope you have Got What is how to post into a facebook page with php using graph api And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.


Related FAQ

Here are some more FAQ related to this Article:

  1.   vuejs crud Insert Update Delete operations Example and demo
  2.   How to Open URL in New Tab using PHP
  3.   vuejs pass multiple parameters to $http post
  4.   Bootstrap Toggle switch example
  5.   How to Post Into Facebook Group with PHP using Graph API
  6.   VueJS nested child, template, inner template, components
  7.   Auto Post on Facebook Page using Facebook PHP API
  8.   Basic Computer Programming Languages Principles
  9.   Calling functions inside Vue.js template
  10.   Auto Post On LinkedIn Using PHP script

Leave a Reply

Your email address will not be published. Required fields are marked *