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>