Windows phone 7 and uploading photo to facebook wall - c#

I am having a problem uploading a photo to a facebook wall. The post shows up on the wall, and the result returned from the apiasync call has no error, but the photo is not there :(
I am using the facebook sdk from http://facebooksdk.codeplex.com
Here is my code, any help would be appreciated!!!
var photo = new WriteableBitmap(0, 0).FromResource("Background200x200.jpg");
FacebookClient app = new FacebookClient();
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters["access_token"] = _facebookAccessToken; //set in another method where I authenticate...
parameters["name"] = "my picture";
parameters["message"] = "this is a picture uploaded from my the facebook sdk";
var mediaObject = new FacebookMediaObject {
FileName = "Background200x200.jpg",
ContentType = "image/jpeg",
};
mediaObject.SetValue(photo.ToByteArray());
parameters["source"] = mediaObject;
app.ApiAsync(
UploadComplete,
null,
"https://graph.facebook.com/me/feed",
parameters,
HttpMethod.Post);

Not sure if you're still having this problem, but I'll answer to help future users if you aren't.
The problem is the way you're doing the upload. You need to first upload the picture to a photo album using the /me/photos connection (me can be replaced with the User_ID as well). Once you get the resulting PHOTO ID from the upload you can then make a subsequent call to /me/feed and post the image to the user's wall using the object_attachment parameter.
Both would be done via HTTP POST
You can reference these two documentation pages:
How to upload image via the GraphAPI
Graph API POST reference
Note: As of right now, the object_attachment parameter is undocumented, but works as long as you post a POST and not a STATUS MESSAGE.

Related

Facebook : No permission to publish the video

I am trying to upload video using c# facebook graph api, and its working fine for user development account, i am able to post on wall, but when i try to other user i am getting error :
(OAuthException - #100) (#100) No permission to publish the video
This is my sample code
**var fb = new Facebook.FacebookClient(token);
dynamic parameters = new ExpandoObject();
parameters.source = new Facebook.FacebookMediaObject { ContentType = "video/mp4", FileName = "video.mp4" }.SetValue(File.ReadAllBytes(#"D:\home\site\wwwroot\\Videos\abc.mp4"));
parameters.title = "test title";
parameters.description = "test description";
dynamic result = fb.Post("/me/videos", parameters);**
where i set the permission
**scope=publish_actions**
Please help me, Thank you in Advance.
In order to make publish_actions work for other users without a role in the App, you need to go through Login Review. Everything you need to know about that is in the docs: https://developers.facebook.com/docs/facebook-login/review
If you are indeed trying with an App Admin/Developer/Tester and it still does not work, debug the Access Token in the Debugger and make sure publish_actions is authorized correctly: https://developers.facebook.com/tools/debug/

How to post media on google plus through google api?

private void googleplue()
{
Moment body = new Moment();
ItemScope itemScope = new ItemScope();
itemScope.Id = "replacewithuniqueforaddtarget";
itemScope.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png";
itemScope.Type = "";
itemScope.Description = "The description for the action";
itemScope.Name = "An example of add activity";
body.Object = itemScope;
body.Type = "http://schema.org/AddAction";
MomentsResource.InsertRequest insert =
new MomentsResource.InsertRequest(
plusService,
body,
userId,
MomentsResource.Collection.Vault);
// Moment wrote = insert.Fetch();
}
I tried this but not work please give me any other solution.
Moment isn't the same as posting to Google+ timeline its not possible to post to the Google+ timeline. see Issue 41: Write access to the streams
In order to post moments which isn't the same thing, you need to be able to set request_visible_actions as part of the authentication process and it doesn't appear that its possible to do with with the current version of the C# client library see
If you want to post moments and not write to a user time line then your going to have to figure out how to send the request_visible_actions as part of your authentication. if you do figure out how to do that please post the answer on my question.

Trying to post photos to Facebook using Facebook C# SDK returns exception "Facebook.FacebookOAuthException"

I am trying to upload photo to a page I have created. Unfortunately it returns me the following exception - A first chance exception of type 'Facebook.FacebookOAuthException' occurred in Facebook.dll.
You'd think that I have missed some permission in the "Graph API Explorer", but I have actually checked every single one of them and I am using that Access Token. Obviously the problem is connected to the Access Token, but I am not sure how.
Here is what I have tested and it works fine:
Posting messages on my personal wall
Posting photos in my personal album
Posting messages on my page
And yet when I try to post photos to my page album or to my page wall it returns me that exception.
I use the code from here:
FacebookClient facebookClient = new FacebookClient(accessToken);
dynamic parameters = new ExpandoObject();
parameters.access_token = accessToken;
parameters.source = new FacebookMediaObject
{
FileName = "My_Picture.jpg",
ContentType = "image/jpeg"
}.SetValue(File.ReadAllBytes(#"F:\\My_Picture.jpg"));
//"my" album ID is 12345
//page album id is 67890
facebookClient.Post("/67890/photos", parameters);
I have tried changing /photos to /feed, but it doesn't work either. I have also tried changing the 67890 (album ID) with my page name and page id.
I use VS 2013, C# with WPF, newest version of Facebook SDK C#.
So I reset the permissions and now everything works properly*.
*What I was looking for was posting the photo on the page as the page. Right now the code above posts a photo on the page as a normal user.

Facebook C# SDK - Post to wall

I'm developing an asp.net MVC 3 Facebook app and I am trying to post a message to my wall. Here is my code:
FacebookWebClient client = new FacebookWebClient();
// Post to user's wall
var postparameters = new Dictionary<string, object>();
postparameters["message"] = "Hello world!";
postparameters["name"] = "This is a name";
postparameters["link"] = "http://thisisalink.com;
postparameters["description"] = "This is a description";
var result = client.Post("/me/feed", postparameters);
I can get the access token using client.AccessToken, so I'm assuming I don't have to set it anywhere. This code produces no errors and for the result I get an ID. However, when I bring up my Facebook, I see nothing on my wall nor in my news feed. I'm not sure what I'm missing. I've looked at related questions here at StackOverflow, but I see no reports/questions similar to mine. I've also tried changing the code based on what I've seen in other posts, but to no avail. I also checked my Facebook account settings and I see my application listed with permission to post to my wall. I also tried posting a message to my wall via the Graph API explorer and I'm getting the same result. I get an ID in return, but when I check my Facebook account I see nothing. At been at this for a couple of days. Any help would be greatly appreciated.
Thanks in advance.
[EDIT]
I wonder if something is wrong with my app generated access_token. Using this access_token, as I mentioned in my post, I get the same result using the Graph API explorer. An ID is returned, but no message on my wall. However, if I give the Graph API explorer permission to post to my wall and use its own generated access_token, I can successfully post a message using the explorer. Here's the FB login button code:
<div>
<h1>Login using Facebook</h1>
<p><fb:login-button perms="user_location, publish_stream, email"></fb:login-button></p>
</div>
Basically you need to add an additional parameter into your post parameters.
args["access_token"] = account.access_token;
this is the token of the specific page.
I wont repeat the code, follow here for example: Post On Facebook Page As Page Not As Admin User Using Facebook C# SDK
(second answer)
Did you request right App permissions to Facebook in your action method?
Try: [CanvasAuthorize(Permissions = "user_location, publish_stream, email")]
Did you append the access_token to the URL? See example here. It's also documented here (see Using the Access Token).
/me/feed?access_token=<access_token>
with one small change, your code works fine for me. you have to pass the users auth token into the constructor like this...
var client = new FacebookClient(accessToken);
// Post to user's wall
var postparameters = new Dictionary<string, object>();
postparameters["message"] = "Hello world!";
postparameters["name"] = "This is a name";
postparameters["link"] = "http://thisisalink.com;
postparameters["description"] = "This is a description";
var result = client.Post("/me/feed", postparameters);
this method works for me, although i am not sure which facebook sdk you are using.
i'm using http://facebooksdk.net/ its quite good so if you're not using it i would recommend it

Post comment on a status Facebook C# API

I'm trying to post a comment to a status on Facebook. Basically what I'm doing is something like this:
var parameters = new Dictionary<string, object>(); parameters["message"] = "hello";
fb.Post("/"+id+"/comments", parameters);
Where fb is a FacebookClient object and id is the id of the status.
Unfortunately this doesn't post the comment on recent status. For instance, if I type https://graph.facebook.com/"id"/comments in a web-browser it returns no data if the status is recent, but if the status is old (more than 1 month) it returns the information about the comments on that status.
Is there a way to comment on a status, picture, etc. using this API with C#?
the fb.Post command seems to be correct. I use the same (in vb.net) and it works like expected...
string AccessToken = "...." // User's access token
FacebookClient fb = new FacebookClient(AccessToken);
dynamic parameters = new ExpandoObject();
parameters.message = txtNewComment.Text.Trim();
dynamic result=fb.Post(HiddenMyPostID.Value+"/comments", parameters);
Above is code that i use for posting new comment on any post of facebook. And It's working.
I was having the same issue so I tried few things & this worked for me
var token = "[your access token]";
var fb = new Facebook.FacebookClient(token);
var postId = "173213306032925_74xxxxxxxxxxxxx"; //replace this with your big id which comprises of [userid]_[postid]
var parameters = new Dictionary<string, object>();
parameters.Add("message", "test message");
Console.WriteLine(fb.Post(id+"/comments", parameters).ToString()); // should give new comment's id
Console.WriteLine(fb.Get(postId +"/comments").ToString()); //should give you details
//for deleting
fb.Delete(newly_created_comment_id); //should return true or false
For this, you need to learn about how can you use Graph API and you also need to learn about some parameters like
height should be in integers which indicated the height of the pixels.
redirection should be in boolean and its default value should be true.
width is in integers which indicates the width of pictures in pixels.
There are many more but it can be understood by the standard programmatic interfaces.
When you use the programming language which you prefer should be based on HTTPS requests.
The version of APIs describes that all the requests are firstly in encrypted form and then they are sent via HTTPs requests.
To do so, you need to send make a registration for your application even users are not allowed to log in.
I hope it would work for you. But apart from it, you need to do more researches.
http://wholestatus.com/

Categories