我正在尝试从我的网站通过电子邮件邀请他们使用他们的API来访问Trello。这是API reference。当我尝试邀请用户时,普通重播是"无效密钥"。 这是我的功能:
public function inviteEmployeeToTrello ($email, $name, $isAdmin)
{
// valid organazation id
$organazationTrelloID = '';
// auth token from trello
$trelloAuthToken = '';
$trelloInviteUrl = 'https://trello.com/1/organizations/'.$organazationTrelloID.'/members';
if ($isAdmin == 1)
{
$type = 'admin';
}
else
{
$type = 'normal';
}
$fields = array(
'fullName' => $name,
'email' => $email,
'type' => $type,
'token' => $trelloAuthToken
);
// open connection
$ch = curl_init();
// set the url, number of PUT vars, PUT data
curl_setopt($ch, CURLOPT_URL, $trelloInviteUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// exec
$replyRaw = curl_exec($ch);
$reply = json_decode($replyRaw, true);
// close connection
curl_close($ch);
dd($replyRaw);
}
我也已插入 script src =" https://api.trello.com/1/client.js?key = myTrelloKey"> 如果你能给我一些建议,我很高兴。提前谢谢!