2013-10-11 139 views
1

我試圖通過PHP刪除照片我有一個應用程序上傳如何用捲曲

載示例的結果搶API PHP刪除照片的後期ID Facebook的:

{"id":"429774393794352","post_id":"276744849097308_429774413794350"} 

第一哪一個ID或post_id將被使用

以及如何使用php選擇它?

以及如何才能通過curl庫與PHP代碼刪除

我的想法是,我將所有照片的ID存儲到SQL刪除它任何時候

我上傳的代碼,我用

$file='./'.$new_string; 






$args = array(
    'message' => $message, 
); 
$args[basename($file)] = '@' . realpath($file); 
$ch = curl_init(); 
$url = 'https://graph.facebook.com/album id /photos?access_token='.$accsesss; 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $args); 
$a1=$data = curl_exec($ch); 
print_r(json_decode($data,true)); 
echo'<br/>'; 

我嘗試

$args = array(
    'id' => '276744849097308_429774413794350', 
    'access_token' => $accsesss , 


); 
$ch = curl_init(); 
$url = 'https://graph.facebook.com/276744849097308_429774413794350?method=DELETE&access_token=$accsesss'; 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_POST, true); $a1=$data = curl_exec($ch); 
print_r(json_decode($data,true)); 
echo'<br/>'; 

結果

Array ([error] => Array ([message] => Invalid OAuth access token. [type] => OAuthException [code] => 190)) 
+0

https://developers.facebook.com/docs/reference/api/user/#photos – CBroe

+0

什麼網址HTTP的DELETE以及如何選擇它用PHP? –

+0

向https://graph.facebook.com/PROFILE_ID/photos?method=delete發送POST請求。那可行 ?? –

回答

1
$Curl_Session = curl_init('https://graph.facebook.com/429774393794352'); 
curl_setopt ($Curl_Session, CURLOPT_POST, 1); 
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "method=DELETE&access_token=$masteracsess"); 
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER, 1); 

echo $a8=curl_exec ($Curl_Session); 
curl_close ($Curl_Session); 

感謝您的幫助@CBroe

+0

感謝您的幫助@CBroe –