首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >通过FB Api将图像发布到用户墙

通过FB Api将图像发布到用户墙
EN

Stack Overflow用户
提问于 2011-06-09 17:11:42
回答 1查看 3.9K关注 0票数 1

嗨,我正在尝试从我的FB应用程序向朋友墙发布图像。我有这个代码,但不知道如何附加图像到帖子。它只发布文本。谁有工作的例子?或者我哪里出错了?谢谢。

这里是图片的完整路径-替换为图片的路径这里是我的FB应用的完整路径-替换为fb应用的路径。

代码语言:javascript
运行
复制
FB.ui(
   {
     target_id: '100000505490012',
     method: 'stream.publish',
     message: 'Just Testing!!!.',
     attachment: {
       name: 'test name',
       caption: 'Caption here.',
       description: (
         'description here'
       ),
       href: 'http://facebook.com/mysite'
     },
      media: {
            type: 'image',
            src: 'FULL PATH TO IMAGE HERE',
             href:'FULL PATH TO MY FB APP HERE'
             },
     action_links: [
       { text: 'Code', href: 'FULL PATH TO MY FB APP HERE' }
     ],
     user_prompt_message: 'Personal message here'
   },
   function(response) {
     if (response && response.post_id) {
       alert('Post was published.');
     } else {
       alert('Post was not published.');
     }
   }
 );
EN

回答 1

Stack Overflow用户

发布于 2011-06-15 01:39:07

媒体属性实际上位于附件属性内部。

代码语言:javascript
运行
复制
FB.ui({
  target_id: '100000505490012',
  method: 'stream.publish',
  message: 'Just Testing!!!.',
  attachment: {
    name: 'test name',
    caption: 'Caption here.',
    description: 'description here',
    href: 'http://facebook.com/mysite',
    media: [{ 'type': 'image', 'src': 'FULL PATH TO IMAGE HERE', 'href':'FULL PATH TO MY FB APP HERE'}]
  },
  action_links: [{ text: 'Code', href: 'FULL PATH TO MY FB APP HERE' }],
  user_prompt_message: 'Personal message here'
},
  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  }
);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6290528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档