2013-03-12 80 views
1

我想從我的應用程序發送批次通知,幾個應用程序用戶發送批量應用通知乳寧下面的代碼,我得到的響應錯誤後:無法使用Facebook PHP SDK

"{"error":{"message":"(#100) Must specify a non-empty template `param","type":"OAuthException","code":100}}"` 

雖然模板參數是設置...

欣賞什麼我做錯了任何幫助..

這裏是我的代碼使用方法:

$batched_request = array(); 

foreach ($users as $idx => $user) { 

$request = array(
     'method' => 'POST', 
     'relative_url' => '/' . $user['id'].'/notifications', 
     'access_token' => $app_access_token,          
     'template' => $template,          
     'href' => $href   
    ); 

$batched_request[] = json_encode($request); 

} 

$params = array('batch' => '[' . implode(',',$batched_request) . ']'); 
try { 

    $response = $facebook->api('/','POST',$params); 


} catch(FacebookApiException $e) { 
     error_log($e);    
} 

回答

1

如果您通過批處理API進行發佈,請記住,您應該將模板& href參數作爲http查詢字符串包含在「body」鍵中。

例如:

$apiCalls[] = array(
    "method" => "POST", 
    "relative_url" => $user['id'] . "/notifications", 
    "body" => http_build_query(array("href" => $href, "template" => $template, "ref" => "ref_key")), 
    "access_token" => $app_access_token 
); 
相關問題