简体   繁体   中英

iPhone facebook integration

I am using Graph API in my application. I am fetching user's facebook wall feeds using graph API also getting details of particular post ie (Like count,Comments etc). but i want to allow user to Like and Comment any post from the application itself. what is the request format for that?

Please help me or give any pointers.

Regards, Sanket

You would be well served to check out the Publishing section of the documentation . It provides information such as this.

One example is liking, which is defined as:

Method: /OBJECT_ID/likes

Description: Like the given object (if it has a /likes connection)

Arguments: none

Basically, just initiate a Graph API call to something like:

[facebookObject requestWithGraphPath:@"98423808305/likes" andDelegate:self];

That will "like" a picture from Coca-Cola (ID taken from the documentation).


Edit 1

According to the documentation:

Most write operations require extended permissions for the active user. See the authentication guide for details on how you can request extended permissions from the user during the authentication step.

Are you sure you have enough privileges? Unfortunately the documentation is very unclear as to whether it serves the dual purpose of liking the object and returning the likes already on that object.


Edit 2

I did some more research into what could be causing this and came across this question and answer that indicated that the code I posted above using requestWithGraphPath:: should work. However, it does not due to a bug on Facebook's Bug Tracker .

Unfortunately, it looks like there is no way to "like" an object via the Graph API, which seems very strange to me. Perhaps it is possible with the legacy REST API instead of the Graph API?


Edit 3

Well, it looks like your best bet is the stream.addLike method of the legacy REST API which you can still call using the Facebook iOS SDK. You should be able to use the stream.addLike method to "like" something in the "stream". Unfortunately, it doesn't appear to support photos, videos, etc. Only posts and comments.

Finally i found the solution for LIKE option We should use following method for like option.

-(void) requestWithGraphPath:(NSString *)graphPath 
               andParams:(NSMutableDictionary *)params 
           andHttpMethod:(NSString *)httpMethod 
             andDelegate:(id <FBRequestDelegate>)delegate

graphPath = /OBJECT_ID/likes Paramas = dictionary with comment,for like option use empty dictionary HttpMethod should be POST

you should get response = true if the LIKE request is successful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM