简体   繁体   中英

API Error code: 100 facebook OpenGraph

I have just started making a new Facebook app hosted on heroku and I haven't made any changes yet, but tested the functionality a little bit, to get used to how stuff works. All good until I try the "send message button", to which a dialog appears with the following error log:

An error occurred. Please try later

API Error Code: 100
API Error Description: Invalid parameter
Error Message: 'link' is invalid.

I've looked a bit in the related piece of code, and I find nothing wrong, but I am quite new so maybe any of you can help me a little bit to find out what's wrong:

    $('#sendToFriends').click(function() {
          FB.ui(
            {
              method : 'send',
              link   : $(this).attr('data-url')
            },
            function (response) {
              // If response is null the user canceled the dialog
              if (response != null) {
                logResponse(response);
              }
            }
          );
        });

The reason I don't think there is a problem with $(this).attr('data-url'); is that the following works (the post to wall button):

 $('#postToWall').click(function() {
      FB.ui(
        {
          method : 'feed',
          link   : $(this).attr('data-url')
        },
        function (response) {
          // If response is null the user canceled the dialog
          if (response != null) {
            logResponse(response);
          }
        }
      );
    });

  }

The getUrl() function that gets the value is:

 public static function getUrl($path = '/') {
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)
  || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'
) {
  $protocol = 'https://';
}
else {
  $protocol = 'http://';
}

return $protocol . $_SERVER['HTTP_HOST'] . $path;

}

Can anyone please help me? I've searched a bit on facebook developers forum and on stackoverflow, but the although the error code was the same, the error message was different. I think this problem is from facebook since method feed works, while method send does not. Both methods are defined in the facebook sdk

Note:I am using the latest php sdk

I had this issue using the send dialog only. The feed publishing worked fine which was odd. I was using dynamic querystring parameters on a common URL.

I fixed the issue by forcing Facebook to scrape the URL before I attempt to send it via the FB UI Send Dialog. Use the FB API to hit graph.facebook.com with the URL posted in the id parameter and a scrape parameter set to true .

Like so:

FB.api('https://graph.facebook.com/', 'post', {
    id: '[URL]',
    scrape: true
}, function(response) {
    FB.ui({
        method: 'send',
        name: '[name]',
        picture: '[Picture URL]',
        link: '[URL]',
        description: '[description]'
    });
});

I also answered with this solution to the same problem here .

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