简体   繁体   English

Facebook Cordova插件 - 共享照片(没有链接)导致空的共享对话框

[英]Facebook Cordova plugin - sharing a photo (with no link) results in empty Share Dialog

I'm using the cordova Facebook plugin ( https://github.com/jeduan/cordova-plugin-facebook4 ) in a Meteor mobile app on Android. 我在Android上的Meteor移动应用程序中使用了cordova Facebook插件( https://github.com/jeduan/cordova-plugin-facebook4 )。

I can successfully use the Share Dialog to share a photo with a link (as in the plugin example here: https://github.com/jeduan/cordova-plugin-facebook4#show-a-dialog ). 我可以成功使用共享对话框与链接共享照片(如插件示例: https//github.com/jeduan/cordova-plugin-facebook4#show-a-dialog )。 Ie.. 即..

{
  method: "share",
  href: "http://example.com",
  caption: "Such caption, very feed.",
  description: "Much description",
  picture: 'http://example.com/image.png'
}

However, if I attempt to share a photo-only (ie with no website link)... 但是,如果我尝试分享仅限照片 (即没有网站链接)...

facebookConnectPlugin.showDialog({
  method: "share",
  picture:'https://www.google.co.jp/logos/doodles/2014/doodle-4-google-2014-japan-winner-5109465267306496.2-hp.png',
  name:'Test Post',
  message:'First photo post',
  caption: 'Testing using phonegap plugin',
  description: 'Posting photo using phonegap facebook plugin'
}, function (response) {
  console.log(response)
}, function (response) {
  console.log(response)
});

....the Share Dialog opens, but is empty. ....共享对话框打开,但是为空。

This is exactly as per the final example given on the plugin's github ( https://github.com/jeduan/cordova-plugin-facebook4#publish-a-photo ) so I assume it's a valid use-case. 完全按照插件的github( https://github.com/jeduan/cordova-plugin-facebook4#publish-a-photo )给出的最后一个例子,所以我认为它是一个有效的用例。

Any ideas? 有任何想法吗?

Refer this: 请参考:

  1. https://github.com/jeduan/cordova-plugin-facebook4/issues/36 https://github.com/jeduan/cordova-plugin-facebook4/issues/36
  2. Facebook share content only shares URL in iOS 9 Facebook共享内容仅在iOS 9中共享URL
  3. https://github.com/jeduan/cordova-plugin-facebook4/issues/221 https://github.com/jeduan/cordova-plugin-facebook4/issues/221

and if it still not solved your problem then there is official open issue with this plugin you will need to change the plugin. 如果它仍然没有解决你的问题,那么这个插件有正式的开放问题你需要更改插件。

You need to adjust the method to be "feed" instead of "share" if no link is provided. 如果没有提供链接,则需要将方法调整为“feed”而不是“share”。

Change: 更改:

 method: "share",

To: 至:

 method: "feed",

I had the same issues and finally got it resolved! 我有同样的问题,终于解决了! How? 怎么样? I just did this: 我这样做了:

method: "share",
href: 'url_of_image_or_photo_to_share'

Even after doing it this way, the share dialog was showing like a link or small icon! 即使在这样做之后,共享对话框也显示为链接或小图标! So I went ahead and hit the Post but and saw it like I would expect on Facebook. 所以我继续前进并点击了Post,但看到它就像我期望的那样在Facebook上。

Give it a trial! 试试吧!

1. untrusted ssl cert for https image url 1. https图片网址的不受信任的ssl证书

If the certificate isn't trusted by facebook, it won't preview the image. 如果Facebook不信任证书,则不会预览图像。 See https://rameerez.com/facebook-sharing-not-scraping-url-correctly-with-https-links/ 请参阅https://rameerez.com/facebook-sharing-not-scraping-url-correctly-with-https-links/

2. image has not been cached by facebook 2.图像尚未被facebook缓存

https://developers.facebook.com/docs/sharing/best-practices/ https://developers.facebook.com/docs/sharing/best-practices/

Pre-caching images 预缓存图像

When content is shared for the first time, the Facebook crawler will scrape and cache the metadata from the URL shared. 当第一次共享内容时,Facebook抓取工具将从共享的URL中抓取并缓存元数据。 The crawler has to see an image at least once before it can be rendered. 爬虫必须至少看一次图像才能渲染。 This means that the first person who shares a piece of content won't see a rendered image: 这意味着共享一段内容的第一个人将看不到渲染图像:

在此输入图像描述

To verify whether this is the problem, use the facebook Sharing Debugger: 要验证这是否是问题,请使用Facebook共享调试器:

https://developers.facebook.com/tools/debug/ https://developers.facebook.com/tools/debug/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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