0

WordPress サイトにバニラ API を統合しました。

この API は最新のディスカッションを一覧表示しますが、ページがリロードされない限り、ディスカッションの変更は更新されません。必要なのは、次の行で動作し、x 秒ごとにディスカッションを取得する関数だけです。

// Retrieve the latest discussions from the Vanilla API
$resturl = vf_combine_paths($resturl, '/');
$data = json_decode(vf_rest($resturl));
if (!is_object($data))
   return;
4

1 に答える 1

0

Javascript タイマーを使用します。

// retrieves the discussions every 30 seconds
setInterval ( "refreshDiscussion()", 30000 );

// Retrieve the latest discussions from the Vanilla API
function refreshDiscussion(){
    $resturl = vf_combine_paths($resturl, '/');
    $data = json_decode(vf_rest($resturl));
    if (!is_object($data))
    return;
}
于 2011-12-10T17:54:43.860 に答える