Http删除?删除一个像?

问题描述:

我不能为我的生活弄清楚如何建立一个连接,以删除我喜欢从ios Facebook SDK中的帖子。这是我的代码喜欢连接。我如何删除类似的东西?我无法启动startForDelete连接。Http删除?删除一个像?

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

您正在发出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"]; 
+0

真棒,谢谢! – 2013-04-24 12:58:47