Upload photos for past date
Asked Answered
A

3

11

I am trying to upload few old photos with a past creation date so that they appear properly in timeline. Existing api allows only to pass message and source.

i.e

  POST https://graph.facebook.com/ALBUM_ID/photos?access_token=xyz
  ..multipart.form.data.with.message.and.source..

is the only way I can upload photos.

  POST https://graph.facebook.com/PHOTO_ID?access_token=xyz
  created_time=2010-01-20T09:04Z&updated_time=2010-01-20T09:04Z

doesn't move the photo date either.

I tried creating a post out of the photo upload using the /feed api, but it doesn't allow me to make an existing photo a post. It makes it a post of type link.

What I want to exactly create a photo object and publish following:

  {
    "id": "xx_yy",
    "from": {
       "name": "My Name",
       "id": "myfbid"
    },
    "story": "<My Name> added a new photo.",
    "picture": "<PhotoJPEG>",
    "link": "<FBPhoto_URL>",
    "name": "Photo Name",
    "icon": "https://s-static.ak.facebook.com/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
    "actions": [
       {
          "name": "Comment",
          "link": "https://www.facebook.com/xxx/posts/yy"
       },
       {
          "name": "Like",
          "link": "https://www.facebook.com/xx/posts/yy"
       }
    ],
    "privacy": {
       "description": "Group",
       "value": "CUSTOM",
       "friends": "SOME_FRIENDS",
       "allow": "<GROUPID>"
    },
    "place": {
       "id": "<placeid>",
       "name": "<PlaceName>"
    },
    "type": "photo",
    "object_id": "12345",
    "created_time": "2010-09-20T13:37:54+0000",
    "updated_time": "2010-09-20T13:37:54+0000",
    "comments": {
       "count": 0
    }
  }
Aer answered 20/12, 2011 at 13:55 Comment(2)
For what it's worth, I spoke with Nick Felton at Facebook on Dec 7th and he indicated that this was not possible with the API, but would be soon. I am looking forward to adding old photos too!Phore
I think timeline feature was now a user centric feature and that's not yet available for developers.. Even for users the timeline feature is not available to all... So when every thing false in place, i hope facebook will come up with an option to handle these things through APIMarcum
M
8

I'm an Engineer at FB, but not on the Platform team so I'm not 100% up to date on this. There is an undocumented field 'backdated_time' available on the photo uploader in the Graph API. I assume it's supernew and will be being doc'd over the next few weeks, but feel free to try it in the interim (and report back here!).

It takes an ISO-8601 timestamp by the looks of it.

The docs team have been chased to figure out what's going on.

Also, DMCS isn't quite right. FB Engineers (particularly those in our Developer Support team) are encouraged to hang out here to help with questions, and each week on our developer blog we post how many questions were asked and how many were answered. So there is a commitment to getting questions on SO answered - see https://developers.facebook.com/blog/post/625/ as an example.

However, there's a difference between support of existing features and bugs/requests for new features. If you have a bug or feature request, add it to http://developers.facebook.com/bugs.

Thanks!

Martyr answered 6/1, 2012 at 10:25 Comment(5)
I tried it, it works! Thanks! Working example code in my answer. And.....do you know if there's a similar field for location? I've tried a few guesses (e.g. "location") but nothing's worked.Phore
If the location is already a place in the graph then place and the uid of the place page will probably workMartyr
mrtom, adding an id with place worked a few weeks ago (IIRC), but doesn't now. Please keep bugging the docs team! :)Phore
The team ought to be encouraged to hang out in the official IRC channel as well. Only a few FB employees show up and are silent. I moderate the channel and wind up being one of the only people answering questions, even though the IRC channel is listed as a place to come for help. Please don't forget about us.Animadversion
@AndrewF: there's an official IRC channel? o_ODownstream
M
1

I would assume with how new the timeline is, that this is a Facebook bug or an enhancement that needs to be made to the API. Have you submitted this to Facebook?

Mccloud answered 29/12, 2011 at 23:5 Comment(2)
I haven't submitted this to Facebook, but I thought facebook.stackoverflow.com was the way to talk to FB folks. (developers.facebook.com/blog/post/545)Aer
No, just fellow programmers here. You will need to submit your own bug to developers.facebook.com/bugsMccloud
P
0

The following code works. (Combines this FB example code with mrtom's undocumented field.)

<?php

$app_id = "YOUR_APP_ID";
$app_secret = "YOUR_APP_SECRET";
$post_login_url = "YOUR_POST_LOGIN_URL"; // should be the URL of this script

$code = $_REQUEST["code"];

//Obtain the access_token with publish_stream permission
if(empty($code)) {
  $dialog_url= "http://www.facebook.com/dialog/oauth?"
   . "client_id=" .  $app_id
   . "&redirect_uri=" . urlencode( $post_login_url)
   .  "&scope=publish_stream";
  echo("<script>top.location.href='" . $dialog_url
  . "'</script>");
}
else {

  $token_url="https://graph.facebook.com/oauth/access_token?"
   . "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
   . "&client_secret=" . $app_secret
   . "&code=" . $code;
  $response = file_get_contents($token_url);
  $params = null;
  parse_str($response, $params);
  $access_token = $params['access_token'];

 // Show photo upload form to user and post to the Graph URL
 $graph_url= "https://graph.facebook.com/me/photos?"
 . "access_token=" .$access_token;

 echo '<html><body>';
 echo '<form enctype="multipart/form-data" action="'
 .$graph_url .' "method="POST">';
 echo 'Please choose a photo: ';
 echo '<input name="source" type="file"><br/><br/>';
 echo 'Say something about this photo: ';
 echo '<input name="message"
     type="text" value=""><br/><br/>';
 echo 'ISO Date for this photo: ';
 echo '<input name="backdated_time"
     type="text" value=""><br/><br/>';

 echo '<input type="submit" value="Upload"/><br/>';
 echo '</form>';
 echo '</body></html>';
}

?>
Phore answered 6/1, 2012 at 18:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.