我无法发布Facebook墙的链接。这样就可以了,只有我尝试附加到它的图像才会显示在页面上。
我是否必须做一些特别的事情才能发布图片?
public function shareAction()
{
include_once('/application/modules/social/services/facebook/facebook.php');
$request = $this->getRequest();
$this->_helper->getHelper('viewRenderer')->setNoRender();
$this->_helper->getHelper('layout')->disableLayout();
$return = 'ERROR';
if($request->isPost()) {
$file = TOMATO_APP_DIR . DS . 'modules' . DS . 'social' . DS . 'config' . DS . 'config.ini';
$config = new Zend_Config_Ini($file);
$config = $config->toArray();
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => $config['facebook']['appId'],
'secret' => $config['facebook']['secret'],
'cookie' => true,
));
$options = Array(
'access_token' => $config['facebook']['pageAccessToken'],
'link' => $request->getPost('link'),
'picture' => '@' . $request->getPost('picture'),
'name' => $request->getPost('name'),
'caption' => $request->getPost('caption'),
'description' => $request->getPost('description'),
);
//Zend_Debug::dump($options); die();
$wallPost = $facebook->api('/me/feed', 'post', $options);
$return = 'SUCCESS';
}
echo $return;
}
除了图像外,一切都按预期工作。知道为什么好吗?
答案 0 :(得分:2)
set +H # first turn off history expansion
curl -F \
"picture=http://tycho.usno.navy.mil/gif/moons/m146.gif" \
-F "message=you're looking great tonight!" \
-F "name=Current Moon Phase" \
-F "link=http://www.calculatorcat.com/moon_phases/phasenow.php" -F caption="How the moon appears tonight" \
-F "access_token=111111111111111|2222222222222222222222222|33333333333333333333456n" \
"https://graph.facebook.com/215958041750734/feed"
您可以在https://www.facebook.com/home.php#!/pages/The-Moon/215958041750734
看到结果更新:在@mlunoe指出感叹号由Bash历史扩展器插值之后,我不知道上面如何在没有set +H
的情况下工作。我用单引号测试并没有解决问题,所以在https://unix.stackexchange.com/questions/33339/cant-use-exclamation-mark-in-bash找到set
解决方案