本文整理匯總了PHP中FabrikHelperHTML::facebookgraphapi方法的典型用法代碼示例。如果您正苦於以下問題:PHP FabrikHelperHTML::facebookgraphapi方法的具體用法?PHP FabrikHelperHTML::facebookgraphapi怎麽用?PHP FabrikHelperHTML::facebookgraphapi使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FabrikHelperHTML
的用法示例。
在下文中一共展示了FabrikHelperHTML::facebookgraphapi方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: facebookGraphAPI
/**
* Load the Facebook Graph API
*
* @param string $appId Application id
* @param string $locale locale e.g 'en_US'
* @param array $meta meta tags to add
*
* @return void|string
*/
public static function facebookGraphAPI($appId, $locale = 'en_US', $meta = array())
{
if (!isset(self::$facebookgraphapi)) {
self::$facebookgraphapi = true;
return "<div id=\"fb-root\"></div>\r\n\t\t\t<script>\r\n\t\t\twindow.fbAsyncInit = function() {\r\n\t\t\tFB.init({appId: '{$appId}', status: true, cookie: true,\r\n\t\t\txfbml: true});\r\n\t\t};\r\n\t\t(function() {\r\n\t\tvar e = document.createElement('script'); e.async = true;\r\n\t\te.src = document.location.protocol +\r\n\t\t'//connect.facebook.net/{$locale}/all.js';\r\n\t\tdocument.getElementById('fb-root').appendChild(e);\r\n\t\t}());\r\n\t\t</script>";
}
$document = JFactory::getDocument();
$data = array('custom' => array());
$typeFound = false;
foreach ($meta as $k => $v) {
if (is_array($v)) {
$v = implode(',', $v);
}
$v = strip_tags($v);
// $$$ rob og:type required
if ($k == 'og:type') {
$typeFound = true;
if ($v == '') {
$v = 'article';
}
}
$data['custom'][] = '<meta property="' . $k . '" content="' . $v . '"/>';
}
if (!$typeFound) {
$data['custom'][] = '<meta property="og:type" content="article"/>';
}
$document->setHeadData($data);
}
示例2: facebookGraphAPI
public function facebookGraphAPI($appid, $locale = 'en_US', $meta = array())
{
if (!isset(self::$facebookgraphapi)) {
self::$facebookgraphapi = true;
return "<div id=\"fb-root\"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '$appid', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/$locale/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>";
}
$document = JFactory::getDocument();
$data = array('custom'=>array());
$typeFound = false;
foreach ($meta as $k => $v) {
$v = strip_tags($v);
//og:type required
if ($k == 'og:type') {
$typeFound = true;
if ($v == '') {
$v = 'article';
}
}
$data['custom'][] = "<meta property=\"$k\" content=\"$v\"/>";
}
if (!$typeFound) {
$data['custom'][] = "<meta property=\"og:type\" content=\"article\"/>";
}
$document->setHeadData($data);
}