2013-04-23 433 views
0

我不能爲我的生活弄清楚如何建立一個連接,以刪除我喜歡從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]; 

回答

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"]; 
+0

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