Php Yammer-如何通过api发布到活动流?(菲律宾)

Php Yammer-如何通过api发布到活动流?(菲律宾),php,curl,yammer,Php,Curl,Yammer,我可以“获取”活动流,但不能“发布”到活动流。这似乎是一个技术错误。 这是用于获取活动流的代码: function getActivityStream() { $as=$this->request('https://www.yammer.com/api/v1/streams/activities.json'); var_dump($as); } function request($url, $data = array()) { if (empty($this-&g

我可以“获取”活动流,但不能“发布”到活动流。这似乎是一个技术错误。 这是用于获取活动流的代码:

function getActivityStream()
{
    $as=$this->request('https://www.yammer.com/api/v1/streams/activities.json');
    var_dump($as);
}

function request($url, $data = array())
{
    if (empty($this->oatoken)) $this->getAccessToken();
    $headers = array();
    $headers[] = "Authorization: Bearer " . $this->oatoken['token'];
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query($data) );
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    return json_decode($output);
}
好的,这样就可以了。。。 下面的代码返回Yammer“oops此页面找不到”消息:

function putActivityStream()
{
    $data=array('type'=>'text', 'text'=>'hello from api test call');
    $json=json_encode($data);
    $res=$this->post('streams/activites.json',$json);
}

function post($resource, $data)
{
    if (empty($this->oatoken)) $this->getAccessToken();
    $ch = curl_init();
    $headers = array();
    $headers[] = "Authorization: Bearer " . $this->oatoken['token'];
    $headers[]='Content-Type: application/json';
    $url = 'https://www.yammer.com/api/v1/' . $resource;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $response = curl_exec($ch);
    return $response;
}
其中一个例子来自:


你会踢自己的。您的代码有输入错误。:) 更改:

简单

POST https://www.yammer.com/api/v1/streams/activities.json
Requests must be content-type: application/json.

{
  "type": "text",
  "text": "The build is broken."
}
$res=$this->post('streams/activites.json',$json);
$res=$this->post('streams/activities.json',$json);