上传过去日期的照片

发布于 2024-12-22 06:04:46 字数 1714 浏览 2 评论 0原文

我正在尝试上传一些具有过去创建日期的旧照片,以便它们在时间轴中正确显示。现有的 api 仅允许传递消息和源。

ie

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

是我上传照片的唯一方式。

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

也不移动照片日期。

我尝试使用 /feed api 从照片上传中创建帖子,但它不允许我将现有照片设为帖子。它使其成为链接类型的帖子。

我想要准确地创建一个照片对象并发布以下内容:

  {
    "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
    }
  }

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
    }
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寄离 2024-12-29 06:04:46

我是 FB 的工程师,但不是平台团队的工程师,所以我不是 100% 了解最新情况。 Graph API 中的照片上传器上有一个未记录的字段“backdated_time”。我认为它是超级新的,并将在接下来的几周内进行记录,但请随意尝试一下(并在这里报告!)。

从外观上看,它需要一个 ISO-8601 时间戳。

文档团队一直在追查到底发生了什么。

而且,DMCS 也不太正确。我们鼓励 FB 工程师(特别是我们的开发人员支持团队中的工程师)在这里闲逛以帮助解决问题,每周我们都会在我们的开发人员博客上发布提出了多少问题以及回答了多少问题。因此,我们承诺让相关问题得到解答 - 请参阅 https://developers.facebook.com以 /blog/post/625/ 为例。

但是,对现有功能的支持和对新功能的错误/请求之间存在差异。如果您有错误或功能请求,请将其添加到 http://developers.facebook.com/bugs

谢谢!

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!

人事已非 2024-12-29 06:04:46

我认为,根据时间线的最新情况,这是一个 Facebook 错误或需要对 API 进行增强。您已将此提交至 Facebook 吗?

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?

枕花眠 2024-12-29 06:04:46

以下代码有效。 (将此 FB 示例代码与mrtom 的未记录字段。)

<?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>';
}

?>

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>';
}

?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文