简体   繁体   中英

Facebook javascript api and iPad, Android

I am try to use FB.login method from facebook javascript SDK .Everything is ok on desktop browsers. But I have a problem with iPad and Android (motorola xoom).

unable to post message to recipient has origin www.facebook.com

how it can be resolved ?

I am trying to publish a message to the user wall

FB.login(function(response) {
           if (response.authResponse) {
             log("Info: login successfully");
             fbPublish();
           } else {
             log('User cancelled login or did not fully authorize.');
           }
         });

and when in fbPublish

function fbPublish(){
        log("Debug: fbPublish");
        FB.ui({
          method: "stream.publish",
          attachment: {
             name: uatitle.format(myChoice.question, myChoice.answer),
             href: document.location.href,
             media:[{"type":"image","src":"http:.....","href":document.location.href}]
          },
          action_links: [{ text: 'Vote yourself', href: document.location.href }]
         },
         function(response) {
           if (response && response.post_id) {
             log('Post was published.');
           } else {
             log('Post was not published.');
           }
         }
        );
    }

so , as I said on desktop everything ok / new post is published successfully . but I have an error on mobile devices

You should probably move away from stream.publish asap since it is going to be history and start using graph api for posting.

Publishing looks something like this,

var params = {};
params['message'] = 'Message';
params['name'] = 'Name';
params['description'] = 'Description';
params['link'] = 'http://apps.facebook.com/my-app/';
params['picture'] = 'my-site';
params['caption'] = 'Caption';

FB.api('/me/feed', 'post', params, function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Published to stream !');
  }
});

hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM