Table of Contents
Facebook provide a well known API i.e graph API that previously called Social Graph API . It allow us to embed facebook album to our own website .
Using this Graph API and PHP you can easily create Facebook photo album .
In this below tutorial we will guide you how to fetch Facebook photo album to your website .
We will be creating a simple PHP scripts that allow you to fetch images from your Facebook page .You can also customize as per your needs.
Once our scripts ready ,it will automatically fetch new images when you post on your Facebook page .
To achieve this requirements, first of all you have to create Facebook app and get APP ID and APP Secret key from there. If you are new to creating Facebook APP ,Follow below quick steps
Below we are using foreach loop to fetch facebook albums with cover photo ,name and description
Above you can see a link that points to photos.php for showing all images of the respective album .
Below again using foreach loop to get the image path and name .
For Complete Facebook Graph API reference .visit offical facebook graph API reference page If you have any query ,do write on below comments. I will try my best to reply soon.
To achieve this requirements, first of all you have to create Facebook app and get APP ID and APP Secret key from there. If you are new to creating Facebook APP ,Follow below quick steps
- Access Facebook Developers page and login to your Facebook developer account.
- Navigate to the Apps page.
- Click on Add a New App. A popup would be appear.
- Select a platform to get started. Select Website if you are creating app to use for your website .
- Choose an existing app or type the name of your new app .
- Enter the Contact Email and select app Category. Click on Create App ID.
- Skip the quick start process by clicking on Skip Quick Start link.
- You would be redirected to the Apps Dashboard.
- Click on Settings from the left side navigation menu panel.
- Enter the App Domains (If you looking to text the app in your localhost host then type there 'https://localhost').
- Click on Add Platform button and select Website as a platform.
- Now enter your website URL (https://localhost/facebook-login/) and Save Changes.
- Click on App Review link from left side navigation menu panel. Make your app live and available it for public.
- Now you have successfully created your new facebook app.
- Back to the Apps Dashboard, you’ll see the App ID and App Secret.
Fetch Photo Albums from Facebook using PHP
Here in our main index.php file ,we are going to fetch facebook photo album . You need to mention your newly created facebook APP ID ($app_id)), APP Secret($app_secret) also mention your facebbok page id ($facebook_page_id)
Below we are using foreach loop to fetch facebook albums with cover photo ,name and description
Above you can see a link that points to photos.php for showing all images of the respective album .
Retrieve Photos from Facebook Album using PHP
In this photos.php file ,w ill have to retrieve all photos from an album to display those facebook photos as photo gallery . Initially get album_id, album_name using query string of the URL and access toen from the session . Then retrieve all the photos of a particular album using Facebook Graph API.
Below again using foreach loop to get the image path and name .
For Complete Facebook Graph API reference .visit offical facebook graph API reference page If you have any query ,do write on below comments. I will try my best to reply soon.