I stuck on the Facebook sharing..
All I want is to post an image from my iOS app, with text and applink, that can redirect users to installed app or App Store.
App link works fine, I described some metatags like this:
<meta property="al:ios:url" content="cubeDev://" />
<meta property="al:ios:app_store_id" content="1054030..." />
<meta property="al:ios:app_name" content="My app name" />
<meta property="al:web:should_fallback" content="false" />
<meta property="og:image:width" content="50" />
<meta property="og:image:height" content="50" />
<meta property="og:image" content="https://spb.hh.ru/employer-logo/1625583.png" />
<meta property="og:type" content="website" />
<meta property="og:title" contetn="title" />
<meta property="og:description" content="App description.." />
<meta property="fb:app_id" content="31667067867..." />
Share code also pretty simple:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://176.31.132.151:8000/"];
content.imageURL = [feedCell imageURL];
content.quote = [feedCell text];
FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
shareDialog.mode = FBSDKShareDialogModeNative;
if(!shareDialog.canShow) {
shareDialog.mode = FBSDKShareDialogModeFeedBrowser;
}
shareDialog.fromViewController = self;
shareDialog.shareContent = content;
shareDialog.delegate = self;
[shareDialog show];
Where http://176.31.132.151:8000/ is my app link.
It seems like when you describe an image in meta tags for app link, image url property won't work..
So, my goal is to post an image from app with text, and app link below with my app icon and description..
Will be grateful for any help.
After visiting Facebook bugs page
I found an explanation of this behavior by one of Facebook team's member and it seems like that there is no way to do that with current fb sdk,
the only solution is to create an app link page with dynamically parameters.. not so good as I expected.
Roemer Vlasveld · · Facebook Team Hi Deepak,
...
It turns out that this behaviour is by design. In the past, the
experience with sharing both a photo and a link caused a mixed
experience. Currently, when sharing both a photo and a link, only the
link will be used to create a preview.
The workaround would be to add the photo as an Open Graph image to the
link that will be shared. This might require that each link is unique,
but that will ensure that the preview created (at least in the created
post) uses the image from the provided link.
I will mark this bug as 'By Design', since it reflects intended
behavior. If you still encounter problems with this, feel free to
reopen by leaving a new comment or reply.
Roemer
Related
I am currently working on facebook sharing and it seems there aren't many topics on facebook sharing with C#. Trying to learn something...
I have Open Graph meta tags in one of razor views like below:
<head>
<meta name="viewport" content="width=device-width" />
<title>Hello World!</title>
<meta property="fb:app_id" content="************" />
<meta property="og:site_name" content="www.hello-world.com" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://hello-world.com/home/fbshare" />
<meta property="og:title" content="How are you doing today?" />
<meta property="og:description" content="Great to know you are doing fine." />
<meta name="author" content="Hello" />
<meta property="og:image" content="https://images.pexels.com/photos/2324/skyline-buildings-new-york-skyscrapers.jpg?w=940&h=650&auto=compress&cs=tinysrgb" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="800" />
<meta property="og:image:height" content="420" />
</head>
For normal users I'd like to redirect them to somewhere else from this view like below:
#{Response.Redirect("Somewhere in my application")};
But I do not want to redirect the facebook scraper too. Is there anyway I can identify the facebook or facebook scraper user agent and If I found out that this is facebook user agent do not redirect him anywhere else redirect them from the view to somewhere else.
P.S: According to facebook official documentation I have to find facebook user agent and allow them scrape my Open Graph meta tags but I can't dig a way.
The Facebook crawler needs to be able to access your content in order
to scrape and share it correctly. Your pages should be visible to the
crawler. If you require login or otherwise restrict access to your
content, you'll need to whitelist our crawler. You should also exempt
it from DDoS protection mechanisms.
If content isn't available at the time of scraping, you can force a
rescrape once it becomes available by passing the URL through the
Sharing Debugger.
The Facebook crawler can be identified by either of these user agent strings:
facebookexternalhit/1.1
(+http://www.facebook.com/externalhit_uatext.php)
OR
facebookexternalhit/1.1
Have you tried:
var userAgent = HttpContext.Request.Headers["User-Agent"];
if (userAgent != null &&
userAgent.Contains("facebookexternalhit/"))
{
// Is a Facebook agent
}
else
{
// Is not a Facebook agent
}
Of course, in MVC you should never redirect from a view, only redirect from a controller or a filter.
The facebook App Link is only working after rescraping the url with the facebook url debug tool. Without this step, the facebook app opens the page in the internal web browser. After the rescrape, both the app switching and the navigation to the app store works fine (in case the application is not installed). The head section of the shared link looks like this:
<head>
<meta charset="utf-8">
<title>Title</title>
<meta property="fb:app_id" content="1234567890123456">
<meta property="og:url" content="http://www.myawesomeapp.com/model/{{$model->id}}">
<meta property="og:type" content="website">
<meta property="og:title" content="MyAwesomeApp">
<meta property="og:image" content="{{$model->image}}"/>
<meta property="og:description" content="{{$model->text}}">
<meta property="og:site_name" content="MyAwesomeApp">
<!--applink-->
<meta property="al:ios:url" content="myawesomeapp://model/{{$model->id}}" />
<meta property="al:ios:app_store_id" content="<<random app id for testing>>" />
<meta property="al:ios:app_name" content="MyAwesomeApp" />
<meta property="al:web:should_fallback" content="false" />
The link is shared from the iOS app in the following way:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
[content setContentDescription:model.text];
[content setContentURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://www.myawesomeapp.com/model/%ld", model.id]]];
content.imageURL = model.image ? [NSURL model.image] : nil;
[FBSDKShareAPI shareWithContent:content delegate:self];
Am I doing something wrong or is it a facebook bug? Or maybe I have to automatically call the rescraping tool of after each link shared?
Well, I figured out a hackish way from the php backend side, it solves the problem, but... it's ugly:
$url = 'https://graph.facebook.com/?id=' . urlencode('https://www.myqwesomeapp.com/model/' . $model->id) . '&scrape=true';
$cmd = "curl -X POST " . "'" . $url . "' > /dev/null 2>&1 &";
exec($cmd, null, null);
When content is shared from the iOS app, i notify the backend, and post the shared url to the graph api endpoint with the scrape=true parameter.
I've double checked everything, from my understanding this is all I need to do:
self.inviteContent = [[FBSDKAppInviteContent alloc] initWithAppLinkURL:[NSURL URLWithString:#"http://mywebsite.com"]];
[FBSDKAppInviteDialog showWithContent:self.inviteContent delegate:self];
On mywebsite.com I have this in the heading (example values shown here):
<html>
<head>
<title>My Website</title>
<meta property="al:ios:url" content="appurl://action">
<meta property="al:ios:app_store_id" content="1234567">
<meta property="al:ios:app_name" content="My App">
</head>
<body>
...
</body>
</html>
So the dialog switches over the to the latest Facebook iOS app. I write a message and pick the person I want to send the invite to, hit send and I get this error:
Missing App Link URL
The app link used with this invite does not contain an Android or iOS URL. Developers are required to enter a URL for at least one platform.
What am I doing wrong?
My app handles the custom URL fine because if I enter appurl://action in Mobile Safari it opens my app up.
You need to create an AppLink URL from here/
Choose your application from the list
Fill up the form with equivalent information
Click on Next !
You're done.
Now, you can use that link with your code for invite.
self.inviteContent = [[FBSDKAppInviteContent alloc] initWithAppLinkURL:[NSURL URLWithString:APP_LINK_HERE]];
[FBSDKAppInviteDialog showWithContent:self.inviteContent delegate:self];
The format of that link will be something like https://fb.me/xxxxxxxxxxxxxxxx
All xs will be replace by a digit.
Try to add also og:title and og:type properties, it works for me
<meta property="og:title" content="My App" />
<meta property="og:type" content="website" />
Adding meta tags would solve this, this is snippet of html from app link created via FB. Fb is adding some extra meta tags on it's app link url page, and it also redirects direct to itunes if opened on a browser.
<html>
<head>
<title>app name</title>
<meta property="fb:app_id" content="your fb app id" />
<meta property="al:ios:url" content="Your app link url" />
<meta property="al:ios:app_name" content="your app name" />
<meta property="al:ios:app_store_id" content="your app id" />
<meta property="al:web:should_fallback" content="false" />
<meta http-equiv="refresh" content="0;url=https://itunes.apple.com/WebObjects/MZStore.woa/wa/redirectToContent?id=your app store id" />
</head>
<body>
Redirecting...
</body>
</html>
I am working on an app in which I am trying to share an image with a url via google+. I am using GPPNativeShareBuilder for the same. But its not sharing anything and giving following warning "You cannot attach a link and media to a post at the same time."
Same is mentioned in method description on google forum as
(id) attachImage: (UIImage *) imageAttachment
If there is an existing media attachment, it is replaced. If imageAttachment is nil, this method does nothing and returns nil. This method cannot be called in combination with either setURLToShare: or setTitle:description:thumbnailURL:.
Please suggest me any solution to resolve this problem.
We can not allowed to add image and link same time in the post,
But we can add "meta" in link, Have to add "meta" in the header of the Link page,
And define image in this "meta".
Google use Open Graph (og) meta as Facebook, Here is the sample meta,
<meta property="og:site_name" content="Your Site Name" />
<meta property="og:title" content="Title of the Post" />
<meta property="og:description" content="Description for the post" />
<meta property="og:url" content="URL where you want to redirect on web" />
<meta property="og:image" content="Your image URL" />
Here is the Some Sample site that is good example
http://moz.com/blog/meta-data-templates-123
http://www.bruceclay.com/blog/how-to-use-social-meta-tags/
I'm struggling, trying to implement Facebook Open Graph into my iOS application.
On the iOS code side, everything seems to work fine and I get the automatic confirmation msg that the Open Graph action has been published.
What is weird is that even if I edit the .html object on my server, the object published on facebook doesn't change. I always get the same object again and again. Does anybody know how is that possible?
This is how my object looks like:
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object#">
<title>Group App</title>
<meta property="og:title" content="Test" />
<meta property="og:image" content="http://www.groupapp.org/ita/attuale/icona.png" />
<meta property="og:determiner" content="" />
<meta property="fb:app_id" content="172461289531661" />
<meta property="og:url" content="https://itunes.apple.com/us/app/ruzzle/id504265646?mt=8" />
<meta property="og:type" content="groupappitalia:object" />
Basically, I edit title, image and url; but nothing changes. Always get the same result.
<meta property="og:url" content="https://itunes.apple.com/us/app/ruzzle/id504265646?mt=8" />
That’s the actual address of your OG object. And so naturally this is also where Facebook retrieves the Open Graph info from, because that’s how the Open Graph works.
So you would have to change the attributes of that URL, and not your own page, to have these changes reflected on Facebook.