How to backdate a post - facebook

I'm trying to post a message on the timeline in the past and I get the following error:
"Facebook.FacebookOAuthException : (OAuthException - #100) (#100) You cannot specify a scheduled publish time on a published post"
I tried to put the current date, a past date or a future date; the result is the same.
I think it may be a problem with the way I obtain the unix timestamp.
Here is the code:
public void PostPostsOnTestUserTimeline()
{
string userId = "[TEST_USER_ID]";
var client = new FacebookClient(accessToken);
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article - 39";
parameters.scheduled_publish_time = GetUnixTimestamp(DateTime.Now.AddMinutes(20));
client.Post(string.Format("{0}/feed", userId), parameters);
}
private long GetUnixTimestamp(DateTime dateTime)
{
double secondsDouble = (dateTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds;
return Convert.ToInt64(secondsDouble);
}
Any idea why it crashes?
I am writing on the timeline of a test user created at "created_time": "2013-03-05T12:34:15+0000". If I don't specify the scheduled_publish_time, it works fine.
Thank you,
Iulia

There's no way to backdate feed posts on user timelines - this feature only exists for Pages or for Open Graph publishing

Related

Facebook Graph API Ad Report Run - Message: Unsupported get request

I'm making an async batch request with 50 report post request on it.
The first batch request returns me the Report Ids
1st Step
dynamic report_ids = await fb.PostTaskAsync(new
{
batch = batch,
access_token = token
});
Next I'm getting the reports info, to get the async status to see if they are ready to be downloaded.
2st Step
var tListBatchInfo = new List<DataTypes.Request.Batch>();
foreach (var report in report_ids)
{
if (report != null)
tListBatchInfo.Add(new DataTypes.Request.Batch
{
name = !ReferenceEquals(report.report_run_id, null) ? report.report_run_id.ToString() : report.id,
method = "GET",
relative_url = !ReferenceEquals(report.report_run_id, null) ? report.report_run_id.ToString() : report.id,
});
}
dynamic reports_info = await fb.PostTaskAsync(new
//dynamic results = fb.Post(new
{
batch = JsonConvert.SerializeObject(tListBatchInfo),
access_token = token
});
Some of the ids generated in the first step are returning this error, once I call them in the second step
Message: Unsupported get request. Object with ID '6057XXXXXX'
does not exist, cannot be loaded due to missing permissions, or does
not support this operation. Please read the Graph API documentation at
https://developers.facebook.com/docs/graph-api
I know the id is correct because I can see it in using facebook api explorer. What am I doing wrong?
This may be caused by Facebook's replication lag. That typically happens when your POST request is routed to server A, returning report ID, but query to that ID gets routed to server B, which doesn't know about the report existence yet.
If you try to query the ID later and it works, then it's the lag. Official FB advice for this is to simply wait a bit longer before querying the report.
https://developers.facebook.com/bugs/250454108686614/

How do I get actions posted via the graph to show up in hte users feed and not the activity log?

Currently when my app posts on a users behalf the custom action shows up in the activity log and not on the user's wall. I am expecting the action to show up in /me/feed in the open graph. I am using the c# library. Below is the code I am using:
public async Task JoinSmaxNation(int nationId)
{
dynamic parameters = new ExpandoObject();
parameters.smax_nation = String.Format(_smaxNationUrlFormat, nationId, UserId);
parameters.no_feed_story = false;
parameters.expires_in = 86400;
dynamic result = await _fb.PostTaskAsync("me/smaxsport:join", parameters);
}
It looks like the fb:explicitly_shared=true option was required.

Publish Facebook Post Feed on Facebook Page with Old Date (Year Only)

I'm using the code below to publish posts on Facebook Page using Facebook SDK :
http://facebooksdk.net/ like below
string accessToken = "[AccessTokenValue]";
FacebookClient fb = new FacebookClient(accessToken);
Dictionary<string, object> PostArgs = new Dictionary<string, object>();
PostArgs["link"] = "www.yahoo.com";
PostArgs["message"] = "Test";
PostArgs["name"] = "Test";
PostArgs["caption"] = "Test";
PostArgs["description"] = "Test";
Facebook.JsonObject results = fb.Post("/[PageID]/feed", PostArgs) as Facebook.JsonObject;
And the above code working Good ..but i want to handle another thing on my posts .. I want to create my posts with old dates not with current datetime ... I want to be able to change the created_date ..There is something on facebook when you create a post you can change its creation time by :
Choose the top-right arrow in your post -> Change Date -> Select a year only .. that will allow you to publish post with undefined month or day ...so any suggestion for how can i handle that using Graph API ??????
You can calculate the year first, then do like that:
This API Documentation is located at https://developers.facebook.com/docs/graph-api/common-scenarios/#backdating
Example code of php to calculate the past year (return unix timestamp) for backdated_time parameter was:
<?php
echo strtotime('-1 years');
?>

Can't send a link to my own wall

I am developing a multi protocol client (currently Twitter, Facebook and Google Reader) for Windows using C# and wanted to extend its functions to send links to Facebook (currently I "only" have text status messages, comments and likes).
So I wrote this quite small method here:
public void PostLink(string text, string url)
{
if (string.IsNullOrEmpty(url))
{
PostTextStatus(text);
return;
}
dynamic parameters = new ExpandoObject();
parameters.message = text;
parameters.link = System.Web.HttpUtility.UrlEncode(url);
dynamic result = facebookClient.Post("me/links", parameters);
UpdateNewsFeed();
}
But I get the following error message back from Facebook: "(OAuthException) (#1500) The url you supplied is invalid"
But at least as I read the API docs this should be the right url and I tried it also with my user ID instead of "me" and without the UrlEncode - no luck so far.
Any help appreciated :)
(Using latest stable version für Facebook C# SDK)
The used client is initiated by
facebookClient = new FacebookClient(AccessToken);
dynamic result = (IDictionary<string, object>)facebookClient.Get("me");
if (result != null)
{
LoginSuccessfull = true;
}
}
and the AccesToken and its permissions were retrieved using
IDictionary<string, object> loginParameters = new Dictionary<string, object>
{
{ "response_type", "token" },
{ "appId", appId},
{ "secret", appSecret }
};
Uri redirectUri = new Uri("http://www.li-ghun.de/Nymphicus/");
loginUri = FacebookOAuthClient.GetLoginUrl(appId, null, _extendedPermissions, loginParameters);
with I think quite more than enough permissons:
private string[] _extendedPermissions = new[] {
"user_activities",
"user_birthday",
"user_checkins",
"user_education_history",
"user_events",
"user_games_activity",
"user_groups",
"user_hometown",
"user_interests",
"user_likes",
"user_location",
"user_notes",
"user_online_presence",
"user_photo_video_tags",
"user_photos",
"user_questions",
"user_relationship_details",
"user_relationships",
"user_religion_politics",
"user_status",
"user_subscriptions",
"user_videos",
"user_website",
"user_work_history",
"friends_about_me",
"friends_activities",
"friends_birthday",
"friends_checkins",
"friends_education_history",
"friends_events",
"friends_games_activity",
"friends_groups",
"friends_hometown",
"friends_interests",
"friends_likes",
"friends_location",
"friends_notes",
"friends_online_presence",
"friends_photo_video_tags",
"friends_photos",
"friends_questions",
"friends_relationship_details",
"friends_relationships",
"friends_religion_politics",
"friends_status",
"friends_subscriptions",
"friends_videos",
"friends_website",
"friends_work_history",
"create_event",
"create_note",
"email",
"export_stream",
"manage_friendlists",
"manage_notifications",
"manage_pages",
"offline_access",
"photo_upload",
"publish_actions",
"publish_checkins",
"publish_stream",
"read_friendlists",
"read_insights",
"read_mailbox",
"read_requests",
"read_stream",
"rsvp_event",
"share_item",
"status_update",
"video_upload",
};
Problem has been all the time at myself being stupid - I accidently exchanged the parameters when calling my method so the text of the entry was in the link property and vica versa.
Stupid me :(
I think your issue lies in the URL being posted as the link. Be sure that URL is visible to the linter (https://developers.facebook.com/tools/lint).
Another thing is to try playing with the Graph API Explorer tool and see if you can use it to post a link. If so, then try changing the application drop down to the app you're having issues with and try posting the link again.
In my case i was posting "http://localhost:3000" and facebook reject it. I tried with "www.google.com" and it works
The error I was getting was, even though the URL itself was valid, the og:image was being set to //example.com/example.jpg and missing http: or https:. I blame Facebook for this one, for not accepting a valid URL that any browser will accept, but the Debugger definitely helped identify this and solved the issue.
https://developers.facebook.com/tools/lint

How to mention user/page in post on wall using facebook api?

I've found format
#[id:1:anchor]
where id is user id or page id and anchor is text displayed.
This format is not documented on official facebook dev page, thus working.
What is the status of issue? Are there any alternatives?
There is no way to add tags in text this way via the API. There were loopholes which allowed this to work but they were closed shortly afterwards
i got the solution for this, here the using c# code:
protected void btnPost_Click(object sender, EventArgs e)
{
var client = new FacebookClient("YOUR FB TOKEN HERE");
var parameters = new Dictionary<string, object>
{
{"message", "YOUR STATUS HERE" },
{"tags" , "YOUR FRIENDS FB ID HERE"},
{"place" , "YOUR PLACE ID HERE"}
};
client.Post("me/feed", parameters);
lblPost.ForeColor = System.Drawing.Color.Red;
lblPost.Text = "Status Updated!";