How can I run a php script to display API response with social media information for a contact
You can run php inside smarty, you just need to include it within {php} tags.

{php}
  $result = doSomethingCool();
  $this-&gt;assign('coolStuff', $result);
{/php}

&lt;div&gt;Your social media profile is: {$coolStuff}&lt;/div&gt;


PS instead of hacking the template directly you can add a .tpl.extra file.
See https://civicrm.org/blogs/dave-greenberg/now-its-easier-add-custom-behaviors-templates