. 나는 다음을 사용했다 : -
if ($ user) { // 유효한 세션이있는 로그인 한 사용자가 있음을 알게된다.
// ========= PHP-SDK를 사용하여 페이스 북 그래프 API를 통한 일괄 요청 ======== // 메서드 호출을 배열로 저장 $ queries = array ('method'=> 'GET', 'relative_url'=> '/ '.$user), array ('method '=>'GET ','relative_url '=>'/ '. ('method'=> 'GET', 'relative_url'=> '/ '.$user.'/groups'), 배열 '=>'/ '.$user.'/likes'), );
// POST your queries to the batch endpoint on the graph.
try{
$batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST');
}catch(Exception $o){
error_log($o);
}
//Return values are indexed in order of the original array, content is in ['body'] as a JSON
//string. Decode for use as a PHP array.
$user_info = json_decode($batchResponse[0]['body'], TRUE);
$friends_list = json_decode($batchResponse[1]['body'], TRUE);
$groups = json_decode($batchResponse[2]['body'], TRUE);
$pages = json_decode($batchResponse[3]['body'], TRUE);
는 // =========은 PHP-SDK를 사용하여 페이스 북 그래프 API를 통해 일괄 요청 =====에게
if(isset($_POST['submit_x'])){
if($_POST['message'] || $_POST['link'] || $_POST['picture']) {
$body = array(
'message' => $_POST['message'],
'link' => $_POST['link'],
'picture' => $_POST['picture'],
'name' => $_POST['name'],
'caption' => $_POST['caption'],
'description' => $_POST['description'],
);
$batchPost=array();
$i=1;
$flag=1;
foreach($_POST as $key => $value) {
if(strpos($key,"id_") === 0) {
$batchPost[] = array('method' => 'POST', 'relative_url' => "/$value/feed", 'body' => http_build_query($body));
if($i++ == 50) {
try{
$multiPostResponse = $facebook->api('?batch='.urlencode(json_encode($batchPost)), 'POST');
}catch(FacebookApiException $e){
error_log($e);
echo("Batch Post Failed");
}
$flag=0;
unset($batchPost);
$i=1;
}
}
}
if(isset($batchPost) && count($batchPost) > 0) {
try{
$multiPostResponse = $facebook->api('?batch='.urlencode(json_encode($batchPost)), 'POST');
}catch(FacebookApiException $e){
error_log($e);
echo("Batch Post Failed");
}
$flag=0;
}
}
else {
$flag=2;
}
}
} ?>
을 종료 전에 배치 APi를 보지 못했습니다, 훌륭한 기능! [링크] (http://developers.facebook.com/docs/reference/api/batch/)에 따르면 현재 한계는 50입니다. 1.000 명의 다른 사용자가 있다고 가정 해 보겠습니다. 게시자는 20 명 이상이어야합니다. 요청 (가능한 '짧은 간격'). 이 문제가 될 수 있습니까? – Planetcrypton
나는 그것이 문제가 될 것이라고 생각하지 않는다. 당신은 1000 명의 사용자에게 20 개의 요청을 보낼 수있다. 그러나 항상 사용자를 스팸하지 말 것을 잊지 마라. 내가 언급 한 블로그 포스트에서 당신은 더 많은 정보를 찾을 수있다. 발행물. 사실 포스트의 스크립트는 50 개 이상의 친구에게 게시 할 여러 일괄 API 호출을 수행합니다. –
필자의 경우, 모든 사용자는 (비상식적으로) 서로 관련이 없습니다. 나는 단지 다른 ID의 무리에 게시해야 할 것이다. [이 포럼 게시물] (http://forum.developers.facebook.net/viewtopic.php?id = 56950) 600 초 동안 600 회 전화를 걸 수 있습니다 (2010/2011 년에 다시 기록됨). 그래서 이론 상으로는 10 분 안에 50 * 600 = 30000 개의 게시물을 만들 수 있습니다. – Planetcrypton