Post to Timeline - with a date in the past

Active3 hr before
Viewed126 times

1 Answers


Meta Stack Overflow , Stack Overflow Public questions & answers , Stack Overflow help chat , bash: how to go back to the bottom of history after pressing up?

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


$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= ""
   . "client_id=" .  $app_id
   . "&redirect_uri=" . urlencode( $post_login_url)
   .  "&scope=publish_stream";
  echo("<script>top.location.href='" . $dialog_url
  . "'</script>");
else {

   . "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= ""
 . "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>';


Other "undefined-undefined" queries related to "Post to Timeline - with a date in the past"