I am trying to extract the facebook id from an iframe in order to update a module which will display on the user’s website and link to the fb page.
For example, when I load this iframe:
<iframe src=https://graph.facebook.com/zuck></iframe>
You can see that Mark Zuckerberg has the id of 4. I would simply like to pull this value out of the iframe and assign it to a variable via php. Any ideas on how this can be done?
You can do this pretty easily using the FB javascript API.
In your head, add a JS block with:
… replace zuck with the wanted username, eg. “/” + USERNAME
Async load the FB JS …
Since ID is a public field, you don’t need any extra user login stuff; you can just make a call.
Please note … that is MISSING some usual FB stuff:
FB.init – since we don’t need to do any user session related stuff.
[div id=”fb-root”][/div] – since we aren’t showing any stuff from FB; dialogs, etc. (but with square brackets! 😛 )