Опубликовать изображение на стене пользователя через FB Api - PullRequest
1 голос
/ 09 июня 2011

Привет, я пытаюсь опубликовать изображение на стене друзей из моего приложения FB.У меня есть этот код, но я не знаю, как прикрепить изображение к сообщению.Это только отправляет текст.У кого-нибудь есть рабочий пример?Или где у меня ошибка?спасибо.

ПОЛНЫЙ ПУТЬ К ИЗОБРАЖЕНИЮ ЗДЕСЬ - заменен путем к изображению ПОЛНЫЙ ПУТЬ К МОЕМУ ПРИЛОЖЕНИЮ FB ЗДЕСЬ - замените путь к приложению fb.

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 Ответ

1 голос
/ 14 июня 2011

Атрибут media фактически находится внутри атрибута attachment.

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.');
    }
  }
);
...