开发者

Post on a friend's wall on behalf of a user

开发者 https://www.devze.com 2023-01-13 00:50 出处:网络
I am writing a Facebook application that needs to post on a friend\'s wall on behalf of a user, but out of the scope of a canvas application. I have the following:

I am writing a Facebook application that needs to post on a friend's wall on behalf of a user, but out of the scope of a canvas application. I have the following:

  • App ID
  • App secret
  • publish_stream permissions for the poster

This should theoretically be enough to do what I want to. What I am currently doing:

  1. Use app ID and app secret to get an OAuth token representing my ap开发者_如何学编程plication (see "Authenticating as an Application" here).
  2. Attempting to publish on my friend's wall using a POST on /friends_wall/feed (see here) and the OAuth token retrieved in step 1.

However, this ends up posting on the friend's wall as the friend rather than the user (the app also has publish_stream permissions for the friend). This isn't too unexpected, as nowhere in this process have I specified who the poster should be.

My question is: Is it possible to obtain an OAuth token for an application representing a user? If not, is there any way to post on user's friend's wall outside the scope of a canvas application?

Thanks,

Ashoat


Use below code for posting on friends wall:

NSMutableDictionary *paramspost = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"My test app", @"name",
                                   @"http://www.google.com", @"link",
                                   @"FBTestApp app for iPhone!", @"caption",
                                   @"This is a description of my app", @"description",
                                   @"Hello!\n\nThis is a test message\nfrom my test iPhone app!", @"message",
                                   nil];

// Publish.
// This is the most important method that you call. It does the actual job, the message posting.
[ facebook requestWithGraphPath:@"100001433267690/feed" andParams:paramspost andHttpMethod:@"POST" andDelegate:self];

where "100001433267690" should be your friends userid in facebook


Actually, I think I've figured out the answer here. I don't think that there's a way to do it in the new OAuth API, but there does seem to be a way with the older REST API. See the documentation here.

Simply replace step 2 in my question with the above documentation, still using the OAuth token from step 1, and you should be good :)

0

精彩评论

暂无评论...
验证码 换一张
取 消