Вопрос

I cannot for the life of me figure out how to make a connection to delete my like from a post in the ios Facebook sdk. Here is my code to like the connection. How do I delete the like? I cannot make the startForDelete connection.

// create the connection object
        FBRequestConnection *newConnection = [[FBRequestConnection alloc] init];

        // create a handler block to handle the results of the request for fbid's profile
        FBRequestHandler handler =
        ^(FBRequestConnection *connection, id result, NSError *error){
            // output the results of the request
            [self likeCompleted:connection thisObject:thisObject thisIndexPath:thisPath result:result error:error];
        };

        // vars
        NSString *postString = [NSString stringWithFormat:@"%@/likes", thisObject.itemId];
        FBGraphObject *graphObject = [[FBGraphObject alloc] init];

        // create request
        FBRequest *request = [[FBRequest alloc] initForPostWithSession:FBSession.activeSession graphPath:[NSString stringWithFormat:@"%@", postString] graphObject:graphObject];

        // add the request
        [newConnection addRequest:request completionHandler:handler];

        // add to open conection
        [openFbConnections addObject:thisObject.userId];

        // if there's an outstanding connection, just cancel
        [requestConnection cancel];

        // keep track of our connection, and start it
        requestConnection = newConnection;
        [newConnection start];
Это было полезно?

Решение

You are issuing a POST request, you have issue a DELETE request. Replace:

FBRequest *request = [[FBRequest alloc] initForPostWithSession:FBSession.activeSession graphPath:[NSString stringWithFormat:@"%@", postString] graphObject:graphObject];

with:

FBRequest *request = [[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:postString parameters:nil HTTPMethod:@"DELETE"];
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top