2010-07-29 33 views
5

onlar ı javascript SDK kullanıyorum bir BottonFACEBOOK JS SDK :: duvara

çarptıktan sonra Kullanıcılarımın facebook duvarına bir görüntü göndermek için çalışıyorum bir resmi göndermeden ama bir sorun var nasıl görüntü duvardaki bir bağlantıya benziyor ... ama istediğim bu değil ... bir resim göndermek istiyorum ... durum metin alanınıza bir görüntü bağlantısı koyduğunuzda olduğu gibi ve görüntü

herhangi bir yardım?

FB.ui(
      { 
      method: 'stream.publish', 
      message: 'test', 
      attachment :{ 
        'name': 'i\'m bursting with joy', 
        'href': ' http://bit.ly/187gO1', 
        'caption': '{*actor*} rated the lolcat 5 stars', 
        'description': 'a funny looking cat', 
        'properties': { 
         'category': { 'text': 'humor', 'href': 'http://bit.ly/KYbaN'}, 
         'ratings': '5 stars' 
        }, 
        'media': [{ 
          'type': 'image', 
          'src': 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg', 
          'href': 'http://bit.ly/187gO1'}] 
         }, 
      user_message_prompt: 'Share your thoughts about Connect' 
      }, 
      function(response) { 
      if (response && response.post_id) { 
       alert('Post was published.'); 
      } else { 
       alert('Post was not published.'); 
      } 
      } 

cevap

13

FB.api() yöntemi deneyin:

var wallPost = { 
    message : "testing...", 
    picture: "http://url/to/pic.jpg" 
}; 
FB.api('/me/feed', 'post', wallPost , function(response) { 
    if (!response || response.error) { 
    alert('Error occured'); 
    } else { 
    alert('Post ID: ' + response); 
    } 
}); 

Desteklenen duvar sonrası params here (bkz "Yayıncılık") bir listesini alabilirsiniz.

+0

Ancak KULLANICI DUVARINA GÖRÜNTÜLEME YAZIYOR? – trrrrrrm

+0

@ From.ME.to.YOU iyi bir görüntü, bir bağlantı olarak değil, bir simge olarak bir duvara gönderilecektir. İhtiyacın olan bu mu? Yükleme ile ne demek istiyorsun? – serg

+0

@serg Hey, Bu iyi çalışıyor ama bana arkadaşların duvarlarına nasıl gönderileceğini söyleyebilir misin? Tıklamada görüntüyü arkadaşların duvarına yapıştırıp göndermemeyi tercih edip "sor" diyen bir butona sahip olmak istiyorum. – Surya

12

Kullanıcının duvarındaki bir resmi POST etmek için FB.api ('/ me/feed', ...) yerine FB.api ('/ me/photos', ...) kullanın ve ek olarak erişim belirteci gerekli . Ekli

Kod Örneği geçerli:

FB.login(function(response) { 
    if (response.authResponse) { 
     var access_token = FB.getAuthResponse()['accessToken']; 
     FB.api('/me/photos?access_token='+access_token, 'post', { url: IMAGE_SRC, access_token: access_token }, function(response) { 
      if (!response || response.error) { 
       //alert('Error occured: ' + JSON.stringify(response.error)); 
      } else { 
       //alert('Post ID: ' + response); 
      } 
     }); 
    } else { 
     //console.log('User cancelled login or did not fully authorize.'); 
    } 
}, {scope: 'publish_stream'}); 

Arkadaş Sayfasında Post için: "/ Benim" yerine arkadaş facebook kullanıcı kimliğini girin.

"/"+friends_user_id+"/photos" .... 
İlgili konular