2010-07-29 5 views
5

ich versuche, ein Bild zu meinen Benutzern des Facebook-Pinnwand zu posten, sobald sie ein Botton HitBOOK JS SDK :: wie ein Bild an der Wand schreiben

ich bin Javascript SDK verwenden, aber ich habe ein Problem, das Bild sieht aus wie ein Link in der Wand ... aber das ist nicht, was ich will ... ich möchte ein Bild zu posten ... das gleiche wie wenn Sie einen Bildlink auf Ihrem Status Textfeld setzen und es zu Bild

wird

Hilfe?

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

Antwort

13

Versuchen FB.api() Methode:

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

Sie eine Liste der unterstützten Wand Post params bekommen here (siehe "Publishing").

+0

aber gibt es eine Möglichkeit, Bild an Benutzer WALL UPLOAD? – trrrrrrm

+0

@ From.ME.to.YOU Nun wird ein Bild an eine Wand als ein Symbol, nicht als ein Link. Ist das was du brauchst? Was meinst du mit hochladen? – serg

+0

@serg Hey, das funktioniert gut, aber könntest du mir sagen, wie man auf Freunde Wand posten? Ich möchte einen Knopf haben, der beim Klicken "fragen" würde, ob das Bild auf der Freundeswand gepostet werden soll oder nicht. – Surya

12

Um ein Bild in der Wand des Benutzers zu senden, verwenden Sie FB.api ('/ me/fotos', ...) anstelle von FB.api ('/ me/feed', ...) und zusätzlich Zugriffstoken erforderlich .

Beigefügt ist das Code-Beispiel:

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

auf Freunde Seite schreiben: Geben Sie die Facebook-Benutzer-ID von Freunden anstelle von "/ me".

"/"+friends_user_id+"/photos" .... 
Verwandte Themen