Posting links to Facebook from PHP – not from localhost

While working on an update for one of my SilverStripe modules, I came upon a problem which held me back for some time, changing configurations and doing all kinds of tests.

The thing is – Facebook engine verifies the link you’re trying to post, so the post from localhost fails with “Unknown error”. You need to give Facebook a link it can scrape and extract meta data from it, so for testing purposes use an existing link, and when your test is online try how the regular link would work.