Sample PHP code for retrieving asset via API?

Can someone share some complete example PHP code that we could re-use to:

  1. Authenticate to the API
  2. Get an Asset
  3. Edit the retrieved asset Asset
  4. Update the retrieved Asset

Thanks
Peter

Tags API example PHP
Asked by Peter Mosinskis on Wed 10/4/17 1:17 PM Last edited Wed 10/4/17 1:23 PM
Sign In to leave feedback or contribute an answer

Answers (5)

This answer has been marked as the accepted answer
Sergio Palomino Thu 10/19/17 12:52 PM

I don't know PHP either, but perhaps this older thread could help.

https://solutions.teamdynamix.com/TDClient/Forums/Questions/Details?ID=103572

2 of 2 users found this helpful.

John Borwick Wed 10/4/17 4:11 PM

Here is some Python code using this github example library: https://github.com/borwick/tdapi.

 

#!python
import tdapi
from tdapi.asset import TDAsset

td_conn = tdapi.TDConnection(
    BEID='REDACTED',
    WebServicesKey='REDACTED',
    sandbox=False
)

tdapi.set_connection(td_conn)

for asset in TDAsset.objects.search({'SerialLike': '123'}):
    asset.update({'Tag': 'TAGNUMBER'})
 

1 of 1 users found this helpful.

Peter Mosinskis Thu 10/19/17 5:44 PM

Thanks, Sergio posted an example that got me going so far. I'll share my work back once it's working. 

No feedback

Peter Mosinskis Mon 10/9/17 3:45 PM

Thanks Mark. Instead of writing it myself I thought I'd reach out to see if someone already had some good prototype code instead of reinventing the wheel. I'm more familiar with PHP than with Python. 

No feedback

Mark Sayers Wed 10/4/17 3:50 PM

Hello Peter,

Unfortunately we do not have the expertise in PHP to provide that for you. I can leave this question open/unanswered so other clients may chime in if they have suggestions for you though.

Out of curiosity, is there a reason that you need specifically PHP code for the API call? Are you only doing scripting with it or are you doing other things as well?

Sincerely,
Mark Sayers
TD Support

No feedback