Open graph is a way to optimize your social media presence trough specifying how your content is shown.
If you want more information on what it is and why it is beneficial for you to use it, you can read more about it on this article describing Open Graph
How to use this
It may look a little confusing at first. To make it easies I made it color coded. Just edit in the orange to fit your setup. The blue is the variables it gets assigned to.
The head of your website
This first one is a typical start on your website when you use PHP to automate Open Graph. If you take notice to the comment section you see what kind of <meta> tag they fill.
Create a .php file to include
Create a .php file and include it in the .php webpage document. You can see it in the <?php include("");?> in the code snippet above.
How this works
Now you can copy the head of your webpage document for every page you want to use open graph on, and you only need to change 7 variables for it to take effect. The opengraph.php file stay unchanged.
$pageType can be changed to alot of tags like games, tv show, tv serie, restaurant and alot more. You can find them at Facebook dev page. If you do change it, it may need additional tags. It would be smart to create a separate .php file you call instead of opengraph.php. I use article on pages like this one, and website on front page and index pages.
Facebook app ID
You will need a Facebook App ID for this to work. It is done with these simple steps:
- Go to Developer tab and click on it.
- Then go to Website Option.
- Enter the app name which you have want.
- Click on Create Facebook App.
- After this you have to choose category, you can choose App for Pages.
- Your AppId and Appkey is created automatically.