die('test')
我已经通过在函数的第一行放置一条语句来检查此触发器是否正常onContentAfterSave()
工作。我想知道为什么里面的其余代码不起作用。
defined('_JEXEC') or die ('Access Deny');
class plgContentMypost extends JPlugin {
public function onContentAfterSave( $context, $article, $isNew )
{
require_once JPATH_ROOT . '/plugins/content/mypost/src/facebook.php';
$appId = '233015226851759';
$secret = '95daba36aa48679229e';
$returnurl = 'http://localhost/sample/examples';
$permissions = 'manage_pages, publish_stream, publish_actions';
// Create our Application instance (replace this with your appId and secret).
$fb = new Facebook(array(
'appId' => $appId,
'secret' => $secret,
));
$access_token = $fb->getAccessToken();
$name = 'LUPIN';
$message = 'this is a message';
$description = 'this is my description';
$pictureUrl = 'http://rofi.philfire.com.ph/joomla16/images/iphone-4-top-new-1.jpg';
$link = 'http://rofi.philfire.com.ph/joomla16/';
$attachment = array(
'access_token' => $access_token,
'message' => "$message",
'name' => "$name",
'description' => "$description",
'link' => "$link",
'picture' => "$pictureUrl",
// 'actions' => array('name'=>'Try it now', 'link' => "$appUrl")
);
$post_id = $fb->api("me/feed","POST",$attachment);
}
}
如果我将此代码用作独立代码,它可以正常工作并在 Facebook 上发布内容。
require_once '/src/facebook.php';
$appId = '233015226851759';
$secret = '95daba36aa48679229e';
$returnurl = 'http://localhost/sample/examples';
$permissions = 'manage_pages, publish_stream, publish_actions';
// Create our Application instance (replace this with your appId and secret).
$fb = new Facebook(array(
'appId' => $appId,
'secret' => $secret,
));
$access_token = $fb->getAccessToken();
$name = 'LUPIN';
$message = 'this is a message';
$description = 'this is my description';
$pictureUrl = 'http://rofi.philfire.com.ph/joomla16/images/iphone-4-top-new-1.jpg';
$link = 'http://rofi.philfire.com.ph/joomla16/';
$attachment = array(
'access_token' => $access_token,
'message' => "$message",
'name' => "$name",
'description' => "$description",
'link' => "$link",
'picture' => "$pictureUrl",
// 'actions' => array('name'=>'Try it now', 'link' => "$appUrl")
);
$post_id = $fb->api("me/feed","POST",$attachment);
下面是我的 XML 文件:
<?xml version="1.0" ?>
<extension type="plugin" version="2.5.0" method="upgrade" group="content">
<name>My Post</name>
<author>Mark Orosa</author>
<version>1.0.0</version>
<description>This is My FB Post Plugin</description>
<files>
<filename plugin="mypost">mypost.php</filename>
<folder>src</folder>
<filename>mypost.xml</filename>
<filename>index.html</filename>
</files>
<config></config>
</extension>