Zendesk壁盘自定义小部件


zendesk geckoboard custom widget

我们正在利用Geckoboard.com和Zendesk。

我正在为Geckoboard创建一个自定义小部件以获取一些信息(顶级票务解决者)并列出它们。

现在,我只是试图将一些虚拟/硬编码的信息推送到小部件。

我的代码如下:
<?php
$curl = curl_init('https://COMPANY_SUBDOMAIN.zendesk.com/api/v2/views/MY_ZD_VIEW_ID/execute.json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);                         
curl_setopt($curl, CURLOPT_USERPWD, 'USER_EMAIL/token:MY_UNIQUE_KEY');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);                         
$values = array(
    "api_key"   =>  "MY_UNIQUE_KEY",
    "data"      =>  array(
        "item"      =>  array(
            "title"     =>  "hello",
            "text"      =>  "Some text here"
        )
    )
); 
$v = json_encode($values);
curl_setopt_array($ch = curl_init(), array(
    CURLOPT_URL => "https://push.geckoboard.com/v1/send/MY_WIDGET_ID",
    CURLOPT_POSTFIELDS => $v,
    )
);
curl_exec($ch);
curl_close($ch);
?>

CAPS中的所有数据都是我自己的信息。

执行文件时得到的消息:

{"message":"属性'text'未定义"}

任何帮助都将非常感激。

对不起,我对JSON还是比较陌生的&旋度

我已经设法解决了这个问题。工作代码如下:

<?php
$curl = curl_init('https://{YOUR ZENDESK SUBDOMAIN}.zendesk.com/api/v2/views/{VIEW ID}/execute.json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, '{EMAIL}/token:{TOKEN}');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$responseToday = curl_exec($curl);
$resultsToday  = json_decode($responseToday, true);
$values = array(
        "item" => array(
            "type" => 1,
            "text" => "Some text here"
        )
);
$v = json_encode($values);
//Simply print this out for the client to consume
echo $v;
/* We don't need this if we're not pushing the widget
curl_setopt_array($ch = curl_init(), array(
    CURLOPT_URL => "https://push.geckoboard.com/v1/send/{UNIQUE ID}",
    CURLOPT_POSTFIELDS => $v
));
curl_exec($ch);
curl_close($ch);
*/
?>