i'm trying invite person via email trello website. here api reference. when try invite him, plain reply "invalid key". here function:
public function inviteemployeetotrello ($email, $name, $isadmin) { $organazationtrelloid = 'myorganazationid'; $trelloauthtoken = 'mytrelloauthtoken'; $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 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($ch); }
curlopt_postfields not want json, if want urlencoded request, use http_build_query($fields) , or if want multipart/form-data request, give $fields array directly. (the api doc's doesn't seem mention request types accept, though. urlencoded common one.)
Comments
Post a Comment