Post

4 followers Follow
0
Avatar

How to Add a Comment

Ive been at this for too long with no success ... hence the messy code ...

Im trying to add a comment to the item with "ref_id" produced from the below code of an item creation:

$item->save();

return $item; <<------ Products my ref_id

my code for adding:

function createComment($refid,$comment,$emailFrom,$vbDate)
{

$comment = new PodioComment('item',$refid,array('value'=> $emailFrom.' wrote on '.$vbdate.':'.ltrim($comment,400)));

}

Im definitely doing something wrong..this is the last part of my code i cant get right..

thanks

Albert Bunick Answered

Please sign in to leave a comment.

7 comments

0
Avatar

PodioComment objects does not currently have a save method, so you have to use the static method for sending values to the API. Merely creating an object does not send any data to the API. Some details around making API requests: http://podio.github.io/podio-php/api-requests/

To create a comment:

PodioComment::create('item', $item_id, array('value'=> $emailFrom.' wrote on '.$vbdate.':'.ltrim($comment,400)));
Andreas Haugstrup Pedersen 0 votes
0
Avatar

Using that method i got the following error.

Fatal error: Uncaught PodioForbiddenError: "The user with id #### does not have the right comment on item with id 173019127" Request URL: http://api.podio.com/comment/item/##### Stack Trace: #0 /home/public_html/podiophp/lib/Podio.php(293): Podio::request('POST', '/comment/item/1...', Array, Array) #1 /home/public_html/podiophp/models/PodioComment.php(52): Podio::post('/comment/item/1...', Array) #2 /home/public_html/podiophp/emailtoticket.php(94): PodioComment::create('item', '173019127', Array) #3 /home/public_html/podiophp/emailtoticket.php(33): createComment('######', 'Yes i will be w...', '*@*...', '2014-07-06 12:0...') #4 {main} thrown in /home/public_html/podiophp/lib/Podio.php on line 260

Albert Bunick 0 votes
0
Avatar

As the error message suggests, the entity you are authenticating as does now have rights to add a comment on that item. Most likely because comments are disabled for that app or you are authenticating as a user who is not a member of the workspace the app resides in.

Andreas Haugstrup Pedersen 0 votes