Share multiple videos on one page onto facebook page wall - facebook-graph-api

I'm using Facebook C# SDK to post on fan page wall. (I created FBApp ext...) and using FB connect (Javascript) to user login, with this scope - "publish_actions,manage_pages,publish_stream". after user login i got an access_token to post on the page.
I have a page, and on the page settings "Everyone can add photos and videos to Testpage's timeline" is checked.
I can post message and picture, but when i tried to post a video (Youtube URL), it's appears on section "Recent Posts by Others on Testpage". When the Everyone can add photos and videos to Testpage's timeline" is not checked, I don't see any post.
To post a video on page, I must enabled "Everyone can add photos and videos to Testpage's timeline"?
When i success to post a video, Why the video appears on "Recent Posts by Others on Testpage"?
My Facebook user is admin on the page and I'm login with this user.
Thank's

To do this, you need to get the access token from the user accounts, and not from the FB.Login.
string getPagesTokensUrl = string.Format(#"https://graph.facebook.com/me/accounts?access_token={0}",accessToken);
using (WebClient wc = new WebClient())
{
var pagesTokens = wc.DownloadString(getPagesTokensUrl);
JObject o = JObject.Parse(pagesTokens);
for (int i = 0; i < o["data"].Count(); i++)
{
if (o["data"][i]["id"].ToString() == ConfigurationManager.AppSettings["YOUR PAGE ID"])
{
return o["data"][i]["access_token"].ToString();
}
}
}

Related

Facebook : Tagging user while posting comments to a post via API not working

I have an app which comments & replies as a Page to the posts.
When i try to post comment with tagging a user on it, this posts the comment without user tagging
Sent to FB as :
Post request sent with active page token
post_id/comments
Sample message #[120232323232323:Bob Jon]
But the message is rendered as
Sample message Bob Jon
There is no link to the User profile.
later, when the User (Bob) posts a comment in FB for the same post,
My tagging works and i can see a link to the user.
Is there any restriction ?

FB.api doesn't bring profile name

I am using Facebook JS sdk to show news feeds. the app works well for many users for for some users who have authorized my app doesn't bring reasonable result.
I use following code to get basic profile info which works for some users but for some it doesn't:
FB.api('/' + id + '?access_token=' + access_token, function (response) {
var strTitle = response['first_name'] + " " + response['last_name'];
});
In response object I receive only id, birth date, email, profile link but name is not available. Interestingly when I open profile link in my browser facebook says:
"Sorry, this page isn't available
The link you followed may be broken, or the page may have been removed."
after that my code can bring its posts but again the from name of the posts is missing in response object. The permissions list is attached as picture.
I can't understand what is going on and how can i fix this issue. Any help please?
The problem is that you are using the App center permissions feature (previously known for Authenticated referrals).
Use these settings to enter the set of permissions your app requires when displayed in App Center
You should be passing a login url with the scope array of permissions in JS SDK.
FB.login(function(response) {
// handle the response
}, {scope: 'email,user_likes'});
or via a login button
<div class="fb-login-button" scope="email,user_likes" data-show-faces="true" data-max-rows="3">Login with Facebook</div

Avoid user login for facebook feed dialog using FB - JS SDK

I have a Rails 3.2 app that uses omniauth gem to authenticate users via Facebook. Once the user is authenticated, i save his FB user_id and access_token that is generated.
I used fb_graph gem to allow users post directly to their friends wall via our app. But recently FB has removed the support of posting to friends wall using their Graph API. This has broken my feature of posting to friends wall using fb_graph gem.
Their documentation says we can post to friends wall via Feed Dialog. Following is the code I wrote for feed dialog:
<p><a onclick="launchFeedDialog(); return false">Testing the Feed Dialog</a></p>
<script>
function launchFeedDialog() {
// calling the API ...
var obj = {
method: 'feed',
to: 'RECIPIENT NAME', // Can specify recipient here
link: 'http://example.com',
name: 'Test post',
description: 'Test description'
};
FB.ui(obj);
}
</script>
When I click on the link, it opens FB dialog asks user to login. I need to avoid this as I have already authenticated the user via FB and have his access token. On clicking the link it should ask user to type message and not ask for user credentials.
How can I do this?
Thanks.

Upload photo to facebook fanpage appcelerator titanium

I have an app that lets me take a pic or choose from my gallery and upload it to my personal fb page.
How can I let it upload to my fanpage instead of my own page?
I use this for putting it in my page:
var data = {picture: image};
Titanium.Facebook.requestWithGraphPath('me/photos', data, "POST", function(e){
if(e.success) {
var d = Titanium.UI.createAlertDialog({
title: Titanium.App.Properties.getString("namn"),
message: 'Uploaded!',
buttonNames: ['Ok'],
});
d.show(); }
It wont just work to change the 'me/photos' to 'pageid/photos'.
What will I have to do to get it to work?
Thanx
As described under the photos secion in the Graph API Documentation for
Page
You should name the parameter source and not picture
Also, make sure you have the publish_stream and manage_pages permissions

facebook create_event posts on my app's wall not the user's wall

i'm attempting to provide a facility on my site that allows a user to create a facebook event for their booking.
http://developers.facebook.com/docs/reference/api/event/
now im doing the correct process:
1) first getting authorisation from the user
https://graph.facebook.com/oauth/authorize?client_id=APP_ID&redirect_uri=http://urlimredirectingto.comtype=web_server
2) requesting for an access token with the "code" that is returned in step 1
https://graph.facebook.com/oauth/access_token
3) using the access_token to create the event ...
string facebookCreateUri = string.Format("https://graph.facebook.com/{0}/events", loggedInMember.FacebookUID);
var formData = new HttpUrlEncodedForm()
{
{"access_token", accessToken},
{"owner", loggedInMember.FacebookUID},
{"description", "nice event that should be on the owners wall"},
{"name", "event on the users wall"},
{"start_time", "1272718027"},
{"end_time", "1272718027"},
{"location", "rochester"},
{"privacy","OPEN"}
};
HttpContent content = HttpContent.Create(formData);
HttpClient client = new HttpClient();
var response = client.Post(facebookCreateUri, "application/x-www-form-urlencoded", content);
but the event is posted on my app's wall, not the user's wall. It shouldn't have anything to do with the authentication/access_token elements because i use the same process to post on the user's wall. (http://developers.facebook.com/docs/reference/api/status/) and that works just fine.
I came back with a solution, after a week of working at many features with Facebook SDK, it finally works!
protected void onPostEvent(object sender, EventArgs e)
{
if (CanvasAuthorizer.Authorize())
{
var fb = new FacebookWebClient(CanvasAuthorizer.FacebookWebRequest);
dynamic parameters = new ExpandoObject();
parameters.description = txtEvDett.Text;
parameters.name = txtEvName.Text;
parameters.start_time = DateTime.Now.ToString("yyyyMMdd");
parameters.end_time = DateTime.Now.AddDays(1).ToString("yyyyMMdd");
parameters.access_token = CanvasAuthorizer.FacebookWebRequest.AccessToken;
dynamic eventDet = fb.Post("me/events", parameters);
litEvent.Text = String.Format("You have created the event with ID: {0}", eventDet.id);
lnkEvent.Visible = true;
lnkEvent.NavigateUrl = String.Format("http://www.facebook.com/event.php?eid={0}", eventDet.id);
}
}
For events, you have to request the create_event permission.
You should use /me/events to post on your events.
I user the C# SDK for Facebook from Codeplex - last version available for dld (aug 2011 - v5.2.1).
Good luck!
I don;t see in your request for Authorization any permission.. base permissions are not enough to do the postings.
i used:
https://www.facebook.com/dialog/permissions.request?app_id=MY_APP_ID&next=MY_APP_URL&display=page&response_type=code&canvas=1&perms=publish_stream,user_about_me,email
This is in the context of a canvas app. where MY_APP_URL is the url from facebook of the app:
http://apps.facebook.com/MY_APP_NAME_OR_ID
See extended permissions for events and check event's page in documentation
[EDIT] - I came back, sorry, now i did a test, and indeed, it works for me, but only of i post on my app's wall; even if i provided the 'user_events' permission i get this error:
The remote server returned an error: (403) Forbidden when posting on a user's wall.
This being said, i also subscribe to this question.