post a comment to facebook from app - c#

So the goal here is to ask a user to post something to their wall with a specific hashtag , when they do this I would like to post a comment to this post from our app with something like "Thank you for your post, come back to http://www.mysite.com for the next step". So far I successfully query the user's posts , and I am successfully finding the post with the specific hashtag. When I find the post I also get the post_id of the post.
So after reading everything I could find from the docs , I am able to post a comment from the user if I do something like this with graph api. (This is using Facebook c# sdk)
FacebookClient client = new FacebookClient();
client.Post("832586561_10152125349566562/comments", new
{
message = "test message from app"
});
now with this code I am using the user's access_token, and it works fine , but on Facebook it will show up as the user commenting on their own post. That is not what we want , we want the comment to appear to be coming from our app. So I tried using the app access token instead of the user's access_token, and when I try i get an error for not enough permission. I do not even know if this is possible to be done with the app access token. I tried adding all the extended permissions that I could find that had anything to do with publiching and I still get the error for not enough permission , right now I ask for these extended permissions on login.
{ scope: 'email,publish_stream,email,rsvp_event,read_stream,user_likes,user_birthday,publish_actions,manage_pages' });
Does anyone have any idea how I can post a comment to a specific post and have that comment comming from the app?

Related

How do I post to a Facebook Page using the Graph API without having my Facebook App reviewed?

The Facebook documentation has this page called Posting as a Page which I've been following.
I followed the instructions on how to obtain an "immortal" access token for the Page.
I've used the Access Token Debugger to check my token is correct. It has the right AppID, the right ProfileID (for the page), and the right UserID (for the owner of the page). It expires "Never", it is valid, and it has the right scopes: manage_pages, publish_pages, publish_actions, public_profile.
I then used the Facebook SDK for .NET to make the call to the API to post to the Page.
var facebookClient = new FacebookClient(accessToken);
facebookClient.Post(string.Format("{0}/feed", profileID), new
{
message = message
});
The post appears on the Page and if I hover "globe" icon to see it's visibility/accessibility it says "public".
So, it worked right? Well ... no.
It turns out only users assigned a role in the Facebook App can see that post, despite it looking like a normal post and saying it's public. For any other users or those who are not signed in it simply doesn't appear.
The documentation page Page Access Tokens and Permissions says:
Your app might not need to request these permissions because people posting are already set up with a role in your app's dashboard. If this is the case you do not need to submit your app for review. See the Roles tab in App Dashboard.
I notice it says "people" which is a touch ambiguous. Does that mean only Users can publish to a Page without being reviewed? You can't publish as the Page itself without the review?
I've tried adding the page to the "Developers" and "Testers" roles for the app using the Pages ProfileID, but it says it can't resolve that to a UserID or name. That makes sense, roles are for people rather than pages.
EDIT 1:
I've tried using the "Embed Post" function and that gave me a link to the post. I tried using the link with a user that can't see the post and got:
It's not expired, as the users that can see it can still see it. It's interesting that it says you might not be in the audience that can view it, but it's set to public which I believe means everyone should see it.
You need to make your app “live” (see top of Status&Review tab), otherwise content created through it will only be visible to people with a role in the app.
(This has nothing to do with permission review.)

Retrieve access token from serverside code

I am new to developing against Facebook. I need to be able to post to other people's walls from my website, which is c#.NET and asp.net. I've already registered a facebook app to do this.
When I press a button on my website, I want to share content to a list of my own users that have provided me with their facebook URLs. They will have granted the FB app permission to their wall.
There's not a lot of information on how to do this. I need to:
Retrieve a new accesstoken, server side, using Facebook SDK.
Given a facebook url, get a user's profile
Share a link to their wall.
i used php and javascript to connect FB SDK. i don't know it can implement to c#
you can get accessToken by FB.getLoginStatus
developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
you can get some permission for grant what you want by "scope" parameter (look about Graph API)
http://developers.facebook.com/docs/getting-started/graphapi/
share some text to wall(feed) see "Publishing" at Graph API
http://developers.facebook.com/docs/reference/api/publishing/
i hope it help you.
sorry for my English skill.
first download the nuget package or dll from https://github.com/barans/FacebookCsharpSdk
fill the appid and secret from www.facebook.com/developers
var config = new Dictionary<string, object>();
config.Add("appId", "3955.......");
config.Add("secret", "4c1d...............");
config.Add("fileUpload", true); //optional
FacebookClient client = new FacebookClient(config);
this code retrieves the access token
client.getAccessToken();
this code retrieves the current user information which is publicly available. you can replace me with a facebook id like "999999"
client.api("/me", "GET", null));
facebook does not allow server side wall posting to an arbitrary user. you can only post to the current user's wall and first you should ask publish_stream permission. after getting that this piece of code makes a wall post
request.Method = FacebookApiMethodType.POST;
request.Path = "/me/feed";
request.Params = new NameValueCollection();
request.Params.Add("link", "www.arcademonk.com");
request.Params.Add("message", "C# SDK Batch Request Messsage");
you can find the all documentation on github page. hope it helps.

Authorize Vimeo advanced API

I'm having a bit of trouble authorizing my Vimeo account through OAuth. I'm using the following .NET wrapper: http://afsharious.wordpress.com/vimeo-for-windows/vimeodotnet/
I understand that the user has to open a browser to get the verification code which is then needed for logging in through the API/wrapper. However, I need to simply list the videos I have on my Vimeo account on a webpage, so I don't want the user to open a new window and do all the verification-code thing described in the tutorial.
Is there any other way of doing it? I have tried by simply using my Consumer key, Consumer secret, my Access token and my Access Token Secret that I get by registrating a new application on Vimeo. However, this does not work, it seems I cannot log in like that :-(
The code I tried was the following:
Vimeo.API.VimeoClient vimeoClient = new VimeoClient(MyConsumerKey, MyConsumerSecret);
// Login to Vimeo
vimeoClient.Login(MyAccessToken, MyAccessTokenSecret);
// Get videos
Videos videos = vimeoClient.vimeo_videos_getAll(true, null, null, VimeoClient.VideosSortMethod.Default, MyUserId);
Anyone know how to do this? :-)

Issue with posting on business page of facebook using c# sdk

I have read many many articles tonight and still do not understood what I shoud do to post on business page of facebook. Here is my code:
string token = getHtml("https://graph.facebook.com/oauth/access_token?client_id=clientID&client_secret=secretKey&grant_type=client_credentials");
token = token.Replace("access_token=", "");
FacebookClient fbClient = new FacebookClient(token);
var args = new Dictionary<string, object>();
args["message"] = "Testing 12qwe3";
fbClient.Post("/pageID/feed", args);
It always says app not authorized. How to authorize it? I read so many articles, but still not able to do it.
I am posting this after totally failing from researching many articles. Kindly let me know whats wrong?
----UPDATE
I did the first part, by making myself the manager page and then creating an app and then providing that app the ability to manage pages and publish etc...but again another issue when i do so even using the above code i still get the same error.But when i use the tools (GRAPH API EXPLORER) portion of facebook site and select this app and generate a token .I than use that directly in app and it posts fine. Kinldy let me know whats wrong!

Publish content to Facebook

I apologize if this has already been answered, but all the information out there on Facebook publishing is so confusing and conflicting, I haven't been able to get anything to work yet. I'm trying to set up an application that runs on my local server to publish content to my organization's fan page (this will tie in with my WCMS to cross-post content). I believe I want a Facebook Connect application to do this which I've set up properly in Facebook and gotten an application key and secret. Here's the code I'm trying to execute, but each time it's run I get "User has not authorized access" even if I'm just trying to publish to the application wall.
ConnectSession fbSession = new ConnectSession("APP_KEY", "APP_SECRET");
Api fbAPI = new Api(fbSession);
fbAPI.Stream.Publish("hello world");
I've also tried:
fbAPI.Stream.Publish("hello world", null, null, FAN_PAGE_ID, APP_ID);
I've granted my application access to publish on the fan page.
EDIT:
I've tried turning this into a Desktop application instead because it appears as though Javascript needs to be involved in order for it to be a Connect application. Here's the updated session initialization line. This now gives me a "Incorrect signature error."
DesktopSession fbSession = new DesktopSession("APP_KEY", false);
There is a similar question titled "How can I post to a facebook wall from a c# web service?" for which I provided a very lengthy answer, specifically indicating how to post to a page.
casperOne's solution works, however, I found this article to be the best solution.
http://tech.karolzielinski.com/publish-post-of-facebook-page-wall-as-a-page-not-a-user-python-facebook-rest-api
This authorizes the application to post directly to the Fan Page without having to go through an admin account.

Categories