我试图在运行以下代码后从我的应用程序向几个应用程序用户发送批处理通知我在响应中收到错误:
"{"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);
}
答案 0 :(得分:1)
如果您通过批处理API发布,请记住,您应该附上模板& href参数作为“body”-key中的http查询字符串。
例如:
$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
);