Http删除?删除一个?

时间:2013-04-23 18:10:00

标签: ios xcode facebook http http-delete

我不能为我的生活找出如何从ios Facebook sdk中的帖子中删除我喜欢的连接。这是我喜欢连接的代码。我该如何删除?我无法建立startForDelete连接。

// 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];

1 个答案:

答案 0 :(得分:1)

您正在发出POST请求,您已发出DELETE请求。替换:

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

使用:

FBRequest *request = [[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:postString parameters:nil HTTPMethod:@"DELETE"];