Reputation: 5545
GOAL:
I'm building an iOS photo/entertainment app, and have a very simple goal: to upload a photo to Facebook, then share the photo using Facebook's Open Graph stories (e.g. "[user] [verbed] a photo using [app name]").
(It turns out iOS 6's SLComposeViewController
does not allow this natively. I was hoping it would. Boo.)
SITUATION:
I don't have a robust webspace - and don't want one - so if a user clicks on the Open Graph story in their timeline (etc), I would prefer to simply link back to the photo on Facebook.
I can get the photo uploaded - AND retrieve its URL - but I cannot get the Open Graph story to work! Here's where I'm at:
Photo Upload to Facebook Album: OK
I use FBRequest
's requestForPhotoUpload
method from the iOS SDK (latest version as of September 17) and record the photopost
result using batchEntryName
. This is basically lifted straight from the FB Open Graph tutorial.
Photo URL Retrieval: OK
Here I use FBRequest
's requestForGraphPath
method - again basically per the FB OG tutorial. Here is an example of the URL I retrieve back:
https://sphotos-b.xx.fbcdn.net/hphotos-ash3/<long_number_string_with_underscores>_n.jpg
Publish Open Graph Story: DOES NOT WORK
With this, I construct an OG HTTP request as follows:
https://<MY_SITE>.herokuapp.com/repeater.php?fb:app_id=<MY_FB_APP_ID>
&og:type=<APP_NAMESPACE>:photo
&og:title=a+rad+photo
&og:description=%22a+rad+photo%22
&og:image=https://sphotos-b.xx.fbcdn.net/hphotos-ash3/<long_number_string_with_underscores>_n.jpg
&og:url=https://sphotos-b.xx.fbcdn.net/hphotos-ash3/<long_number_string_with_underscores>_n.jpg
&body=a+rad+photo
But this does not work. The problem I encounter might be obvious to the veterans: FB's image is returning an og:type
of website
(this must be derived from static OG tags on FB's page?), and so the OG story fails.
I think you can get my OG results here (from the debugger):
https://graph.facebook.com/120073804807493
(I have also tried return my entire OG request as the og:url
, but that just links back to a blank page on my webserver - see repeater.php code below.)
So...what can I do about it? How might I get this to work? Do I really need to spin up an entire web property just to host and display images when all I'm building is an iOS app and all I want to do is post to a user's photo album?!
More Info: Here is the source for repeater.php (see: FB OG tutorial), if it matters:
<?php
function curPageURL() {
$pageURL = 'http://';
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
<html>
<head prefix="og: http://ogp.me/ns# product: http://ogp.me/ns/product#">
<meta property="fb:app_id" content="<?php echo strip_tags($_REQUEST['fb:app_id']);?>">
<meta property="og:url" content="<?php echo strip_tags($_REQUEST['og:url']);?>">
<meta property="og:type" content="<?php echo strip_tags($_REQUEST['og:type']);?>">
<meta property="og:title" content="<?php echo strip_tags($_REQUEST['og:title']);?>">
<meta property="og:image" content="<?php echo strip_tags($_REQUEST['og:image']);?>">
<meta property="og:description" content="<?php echo strip_tags($_REQUEST['og:description']);?>">
</head>
<body>
<?php echo strip_tags($_REQUEST['body']);?>
</body>
</html>
Upvotes: 0
Views: 1000
Reputation: 5545
After much research, regretfully I don't think it's possible to use photos you upload to Facebook as Open Graph objects. Facebook's pages simply aren't marked-up dynamically enough for one of their photos to be an Open Graph object (understandably), so we're on our own.. ;)
(Though I strongly suspect that in iOS 6.1 or 7.0 they will allow something like this; I have to imagine demand for this skyrocketing with SLRequest coming in to fashion..)
Ideas for others who may come across this in the future:
Upvotes: 1