如何做简单的Facebook状态帖子与文字和图片 [英] How to do simple Facebook status post with text and picture

查看:507
本文介绍了如何做简单的Facebook状态帖子与文字和图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaScript API。我可以做一个简单的文本帖子,没有问题:

  var params = {}; 
params ['message'] ='文本';
FB.api(me / feed,'post',params,function(response){
if(!response || response.error)
alert(response.error.message );
else
alert('Post ID:'+ response.id);
});

添加图片:

  params ['picture'] =http://mysite.com/link-to-picture; 
params ['type'] =photo;
...

使用乱码链接发布链接状态,使用图片作为缩略图。



如果我使用我/照片,它可以第一次工作正常:

  var params = {}; 
params ['message'] ='文本';
params ['url'] =http://mysite.com/link-to-picture;
FB.api(me / photos,'post',params,function(response){
if(!response || response.error)
alert(response.error.message );
else
alert('Post ID:'+ response.id);
});

但是,如果我做另一个帖子,我丢失了我的Feed中的第一个帖子,并获得一个专辑在Feed中输入演示文稿,其中包含第二篇文章的文本以及两个(不相关的)图片



我已经能够使用自己的文本获得不同的状态帖子的唯一方法图片是首先创建一个序列号相册,然后将图片发布到该图片。

  var aparams = {}; 
aparams ['name'] =post+ postid;
aparams ['message'] =专辑的帖子+ postid;
FB.api(me / albums,'post',aparams,function(response){
if(!response || response.error)
{
alert 创建相册:+ response.error.message);
}
else
{
alert('Album ID:'+ response.id);
var aid = response.id;
params ['url'] =http://mysite.com/link-to-picture;
FB.api(aid +/ photos,'post' ,params,function(response){
if(!response || response.error)
alert(Posting photo:+ response.error.message);
else
alert('Post ID:'+ response.id);
});
}
});

这不是正确的方法 - 创建大量的单张相册! / p>

我注意到我默认有一个时间轴照片专辑,所以我可以得到它的ID,然后上传图片。但是那么我该怎么做FB.api(我/ feed...)的帖子只用文本,并参考图片。我在文档中找不到这样的东西。



我的要求似乎非常基本。有没有人能够正确的?

解决方案

Facebook会以特定的时间间隔自动检测到相册中上传的图片为单发布和分享他们。它也是通过应用程序来保护垃圾邮件。


I'm using the JavaScript API. I can do a simple text post with no problem:

var params = {};
params['message'] = 'The text';
FB.api("me/feed", 'post', params, function(response) {
   if (!response || response.error)
      alert(response.error.message);
   else
      alert('Post ID: ' + response.id);
});

Adding a picture with:

params['picture'] = "http://mysite.com/link-to-picture";
params['type'] = "photo";
...

Posts a link-type status with a garbled link, using the picture as a thumbnail.

If I use "my/photos", it works fine the first time:

var params = {};
params['message'] = 'The text';
params['url'] = "http://mysite.com/link-to-picture";
FB.api("me/photos", 'post', params, function(response) {
   if (!response || response.error)
      alert(response.error.message);
   else
      alert('Post ID: ' + response.id);
});

But then if I do another post I lose the first post item from my feed, and get an album type presentation in the feed with the text from the second post, and both (unrelated) pictures

The only way I have been able to get distinct status posts with their own text and picture is by first creating a serial numbered album, and then posting the picture to that.

var aparams = {};
aparams['name'] = "post"+postid;
aparams['message'] = "album for post "+postid;
FB.api("me/albums", 'post', aparams, function(response) {
  if (!response || response.error)
  {
     alert("Creating album: "+response.error.message);
  }
  else
  {
     alert('Album ID: ' + response.id);
     var aid = response.id;
     params['url'] = "http://mysite.com/link-to-picture";
     FB.api(aid+"/photos", 'post', params, function(response) {
        if (!response || response.error)
           alert("Posting photo: "+response.error.message);
        else
           alert('Post ID: ' + response.id);
     });
  }
});

That can't be the right way to do it - creating a mass of single picture albums!

I notice that I have by default a 'Timeline Photos' album, so I could get its ID, then upload the picture to that. But then how would I do the FB.api("my/feed" ...) post with just the text and refer to the picture. I can't find anything like that in the documentation.

My requirement seems to me to be very basic. Has anyone been able to get it right?

解决方案

Facebook automatically detects the pictures uploaded in a album at a certain time interval as single post and clubs them. It is also to secure it from spamming through applications.

这篇关于如何做简单的Facebook状态帖子与文字和图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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