【发布时间】:2011-05-29 10:00:35
【问题描述】:
我无法发布 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;
}
除图像外,一切都按预期工作。知道为什么吗?
【问题讨论】:
-
为什么图片网址前面有@?选项图片参数应该只是一个普通的图片url,前面没有@。
-
不,我知道...但这是我在网上找到的测试:-)
-
如developers.facebook.com/docs/reference/api/post 所述,
picture参数必须包含“指向此帖子中包含的图片的链接”,即类似于example.com/article-thumbnail.jpg。你们提供什么?
标签: php image facebook api post