Facebook API - delete status

前端 未结 6 898
你的背包
你的背包 2021-01-02 20:29

In PHP, I\'m using curl to send a delete to the fb graph api - and yet I\'m getting the following error;

{\"error\":{\"type\":\"GraphMethodException\",\"mes         


        
6条回答
  •  长发绾君心
    2021-01-02 21:07

    I modified your code slightly. (Should echo "true" if done correctly) Here's what is currently working for me.

    Also note this does not erase events created via Facebook.That's why your receiving the permissions error. This only erases events created through your application... (application linked to $app_id, $app_secret)

    //First authenticate a token
    
    
    $app_id = "APP ID GOES HERE";
    $app_secret = "SECRET APP ID GOES HERE";
    $my_url = "WHATEVER THIS PAGES NAME IS GOES HERE";  
    
    
    //I'm not sure but I think REQUEST is still allowed....right? if not change it to GET/POST
    
    $code = $_REQUEST["code"];
    
    if(empty($code)) {
    $auth_url = "http://www.facebook.com/dialog/oauth?client_id="
    . $app_id . "&redirect_uri=" . urlencode($my_url)
    . "&scope=create_event";
    echo("");
    }
    
    $token_url = "https://graph.facebook.com/oauth/access_token?client_id="
    . $app_id . "&redirect_uri=" . urlencode($my_url)
    . "&client_secret=" . $app_secret
    . "&code=" . $code;
    $access_token = file_get_contents($token_url);
    
    
    
    
    //Use TRUE and FALSE not 0 and 1's like you originally had it
    
    //264853420218553 is the event id.
    
    $ch = curl_init("https://graph.facebook.com/264853420218553?" . $access_token . ""); 
    curl_setopt($ch, CURLOPT_VERBOSE, TRUE); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    curl_setopt($ch, CURLOPT_HEADER, FALSE); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 120);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $query); 
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);  
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_CAINFO, NULL); 
    curl_setopt($ch, CURLOPT_CAPATH, NULL); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
    
    $result = curl_exec($ch); 
    echo $result;?>
    

提交回复
热议问题