PHP PUT example

52 views
Skip to first unread message

Sean M

unread,
May 2, 2014, 12:04:28 PM5/2/14
to valenc...@googlegroups.com
This is a really basic question, apologies in advance for missing resources that must exist somewhere.

I'm looking for a PHP code sample that shows a Valence PUT request --- ideally something simple like /grades/final/values/[d2lid]

The PHP SDK Getting Started has a couple of get requests, and those are working fine. I also took a look at the Python sample that shows this but it's the language-specific help I need.

Thanks in advance for any help.

Desire2Learn Staff: Viktor

unread,
Jun 3, 2014, 1:10:49 PM6/3/14
to
Sean, sorry for the delay in a response; I'm not typically a PHP person, so I left this behind assuming it would get handled by someone else. However, it does occur to me that if your App Id/Key pair and a User Id/Key pair are working as demonstrated by a GET call, and you're getting a problem with a PUT call (and the problem is an 'invalid token' as reported by the account manager you've been talking to here), then it's possible that you're not specifying 'PUT' as the HTTP method to use when you're generating the signatures for the call?

This can sometimes be an inadvertent error that can cause "invalid tokens" because the signatures you build don't match the Route/HTTP Method/timestamp base string the service is expecting for the call...

Sean M

unread,
Jun 3, 2014, 1:42:38 PM6/3/14
to valenc...@googlegroups.com
Thanks Viktor. I know you're elsewhere on the language spectrum and had hoped someone would jump in here.

From what little I've been able to experiment since asking, it seems that you're right -- there is something in the mechanism of the PUT that's making Valence think my tokens are invalid.

*update*  Actually, it's working now. The problem was indeed the PUT, but we were using a REST library for actually sending off the cURL request, and that library was POSTing the PUT.  Made that change and it's returning a 200. Yippee!

Desire2Learn Staff: Viktor

unread,
Jun 3, 2014, 1:45:06 PM6/3/14
to valenc...@googlegroups.com
Aaargh. YES. I believe you are not the first person to fall into this problem. PHP's cURL library requires very, very particular handling to get it to properly do PUT requests, I understand, and I do not exactly know what that is. I'm glad you seem to have sussed it out.
Reply all
Reply to author
Forward
0 new messages