发布图片到Facebook涂鸦墙 [英] Post a picture to a facebook wall

查看:105
本文介绍了发布图片到Facebook涂鸦墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有T功能来发布链接到一个Facebook的墙。这就像它应该,只有图像我尝试连接到它在页面上显示不出来。

I have t function to post a link to a Facebook-wall. This works like it should, only the image I try to attach to it doesn't show up on the page.

我必须做一些特殊的张贴图片?

Do I have to do something special to post an image?

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;
}

一切正常,除了形象。知道为什么吗?

Everything works as expected except the image. Any idea why please?

推荐答案

布伦特和akond提到,图片链接不应该是pfixed $ P $'@',它应该是一个简单的网址为(presumably缩略图大小)的图像。这curl命令,例如,作品:

as Brent and akond mentioned, the picture link should not be prefixed by '@', it should be a simple URL to a (presumably thumbnail-sized) image. This curl command, for example, works:

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

更新:我不知道该怎么以上的工作没有了设置+ H 中,后@mlunoe指出,感叹号被猛砸历史扩展插。我用单引​​号测试,并没有解决问题,所以发现在设置解决方案<一href=\"http://unix.stackexchange.com/questions/33339/cant-use-exclamation-mark-in-bash\">http://unix.stackexchange.com/questions/33339/cant-use-exclamation-mark-in-bash

update: I don't know how the above worked without the set +H, after @mlunoe pointed out that the exclamation point is interpolated by the Bash history expander. I tested with single quotes and didn't solve the problem, so found the set solution at http://unix.stackexchange.com/questions/33339/cant-use-exclamation-mark-in-bash

这篇关于发布图片到Facebook涂鸦墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆