Tuesday, 4 April 2017

PHP and TACTIC Rest API

TACTIC 4.6 just introduced a new generic REST API which implements most of the TACTIC API.  This opens up the TACTIC API to almost all programming languages.   There are still some advantages to using the client side libraries for Python and Javascript as there is some custom convenience and logic written in the client side libraries.  However, for many important operations, the rest API is sufficient.  This is especially useful when integrating TACTIC with such platforms as WordPress or Drupal or AngularJS.

Since the TACTIC API functionality is very deep, the first REST implementation has been to only support POST requests.   This provides the access to all of the arguments of the API methods without the inconvenient limitation of using a URL to provide all of the arguments to methods.

The following example will made use of the PHP curl functionality wrapped up in a convenience function.  It is assumed that you already have a login ticket.  A login ticket is any non-expired entry in the "ticket" table in the "sthpw" database.

The following function wraps up all the settings needed to access a TACTIC server:

function executeREST($data) {
    $server = "http://tactic.server.com";
    $login_ticket = "8f096a8359bbc355943f93545684b90e";
    $project = "my_projects";
    $url = $server."/".$project."/rest";
    $data['login_ticket'] = $login_ticket;


    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_FAILONERROR, true);

    $result = curl_exec($ch);
    if (curl_error($ch)) {
        throw new Exception(curl_error($ch));
    }
    $result = json_decode( $result );
    return $result;
}

With this function, we can access the api simply with a single line.  We can start with a simple ping.

$data = [
    'method' => 'ping'
];
echo executeREST($data);

This should print "OK", which means that the code has contacted the TACTIC server and was authenticated.  The method

Next, we can try a simple sobject with a search key:

$data = [
    'method' => 'get_by_search_key',
    'search_key' => $search_key,
];
print executeREST($data);

And we can also use expressions:

$data = [
    'method' => 'eval',
    'kwargs' => json_encode( [
        'expression' => '@SOBJECT(workflow/asset)',
        'single' => true,
    ] ),
];
$result = executeREST($data);

Note the difference in the arguments between this method (eval) and the last (get_by_search_key).  There are two ways for arguments to be passed through and both are valid for either function.  You can use the arguments explicitly or you can wrap the arguments in a kwargs key.  However, the kwargs key is assumed to be JSON encoded and allows for complex data structures to be passed through.  The post interface does not allow for complex data structures, so these should be JSON encoded.

This opens up the TACTIC API to many languages, in particular PHP and Ruby which are used in server side processing of popular web platforms.  All of these platforms have a very weak ability to handle complex data and really have no asset management capabilities.  This API makes it easy to integrate a powerful back-end with these content delivery systems.













71 comments:

  1. Replies
    1. IEEE Final Year projects Project Center in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, project projects for cseAngular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    workday studio online training
    best workday studio online training
    top workday studio online training

    ReplyDelete
  3. Android App Development Company Noida for iOS Apps. Android App Development Services in Noida.
    android app development company in noida

    ReplyDelete
  4. Informative blog. cloudshinepro.com offers industry standards training that will help you in landing a good job. Visit us on Oracle Fusion Product Management India

    ReplyDelete
  5. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website. Sports & Fitness

    ReplyDelete
  6. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website

    Solar Power

    ReplyDelete
  7. App Development Company in Delhi - One of the best Android App Development company in Delhi. We offer best Android application development services
    app development company in delhi

    ReplyDelete
  8. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot.

    SAP Online Training

    SAP Classes Online

    SAP Training Online

    Online SAP Course

    SAP Course Online

    ReplyDelete
  9. Nice post! thanks for sharing. Marriage problem solutions - Are you facing problems in married life? They seems to be unending then do not worry.
    Website: online astrology free

    ReplyDelete
  10. It’s a really very awazing post. I really like it very much. Thanks for sharing.
    antique jewellery

    ReplyDelete
  11. I have read your article, it is really interesting and has lots of useful information. I also recommend it to friends so they can read it and they see the same thing
    Website: Matka Charts

    ReplyDelete
  12. Hello! This is my first visit to your blog! This is my first comment here, so I just wanted to give a quick shout out and say I genuinely enjoy reading your articles.
    Best Adventure Tour Packages

    ReplyDelete
  13. This is my first comment here, so I just wanted to give a quick shout out and say I genuinely enjoy reading your articles. Thanks for sharing.
    SattaMatka | satta result | satta king online | satta king chart | indiansatta

    ReplyDelete
  14. Computer Network Technician are responsible for helping to create, maintain and troubleshoot problems with the hardware and software products used as part of a computer network. They can also take steps to prevent any future problems arising.

    ReplyDelete
  15. Great post! thanks for sharing.! this site are good after reading..so awesome.
    Website: Kalyan Matka

    ReplyDelete
  16. Mobile App Development Company Delhi: We have the Top iPhone Android app developers team, offering custom mobile app development company in delhi.

    ReplyDelete
  17. Thanks for sharing this information. I have shared this link with others keep posting such information.
    Visit : Satta Matka|Jodi chart| panel chart|Matka Guessing Tricks

    ReplyDelete
  18. Hope you will keep on offering good content like this more often. I feel more and more people should know about this
    Website :- AC repair Service

    ReplyDelete
  19. Thank you for sharing such a useful post. Very Interesting Post! I regularly follow this kind of Blog.
    Visit here: matka results

    ReplyDelete
  20. I am very glad to here it is very good post. Thanks for sharing
    Apply for csp

    ReplyDelete
  21. Post is very good its amzazing post I love them thanks for sharing.
    visit here- election result comedy

    ReplyDelete
  22. it is really a great and helpful piece of info. I am glad that you shared this helpful information with us. Please keep us informed like this. Thank you for sharing.
    Assignment Help

    ReplyDelete
  23. Ayonz is a Market Development Company in Sydney provides a service solution that is end-to-end like technology design, manufacturing, supply & brand development for consumer lifestyle products sold in retail, through resellers or online shopping channels.

    ReplyDelete
  24. Play premier league fantasy cricket on India's no.1 App and get a chance to win up to 50 lakhs in every match. Download the app now!

    ReplyDelete
  25. I always like to read a quality content having accurate information regarding the subject and the same thing I found in this post. Nice work
    Visit here :- Punjab state lottery

    ReplyDelete
  26. it is really a great and helpful piece of info. I am glad that you shared this helpful information with us. Please keep us informed like this. Thank you for sharing.
    malaysia visa

    ReplyDelete
  27. it is really a great and helpful piece of info. I am glad that you shared this helpful information with us
    Packers and Movers Gwalior

    ReplyDelete

  28. Top quality blog with unique content and information shared was valuable looking forward for next updated thank you
    Ethical Hacking Course in Bangalore

    ReplyDelete
  29. Post is very good its amzazing post I love them thanks for sharing.
    visit here - cartoon wala funny video

    ReplyDelete
  30. Wonderful blog! Do you have any tips for aspiring writers? I'm planning to start my own site soon but I'm a little lost on everything. Would you suggest starting with a free platform like Wordpress or go for a paid option? There are so many choices out there that I'm totally confused .. Any recommendations? Thanks!
    SEO Expert Gwalior

    ReplyDelete
  31. Wonderful blog! Do you have any tips for aspiring writers? I'm planning to start my own site soon but I'm a little lost on everything.
    Website property in jaipur

    ReplyDelete
  32. Appslure is an award-winning mobile app development company building feature-packed and interactive mobile applications for startups, medium and large enterprises.

    ReplyDelete
  33. it is really a great and helpful piece of info. I am glad that you shared this helpful information with us. Please keep us informed like this. Thank you for sharing.
    Website: Online punjab state lottery

    ReplyDelete
  34. Ducted Air Conditioners is usually a whole home solution that allows you condition multiple rooms or the entire house using just one system. The Indoor Unit is usually located in the ceiling or Under the floor.

    ReplyDelete
  35. Roman Daniels Corporate is one of Australia’s favourite providers of corporate wear and we are looking forward to doing the same great job in New Zealand.

    Roman Daniels Corporate is one of Australia’s favourite providers of corporate wear and we are looking forward to doing the same great job in New Zealand.



    ReplyDelete
  36. I am new here. I like your post very much. It is very usefull post for me.
    website: 5G Infrastructure Market

    ReplyDelete
  37. Nice post...Keep it up...
    Nio Stars Technologies LLP is Best Seo Services Agency in UsA. Search Engine Optimization helps to promote your brand and grow your business on search engine.

    ReplyDelete
  38. Situs stlouisresumeservice merupakan Web Pasang Togel Online Terpercaya Pasaran Terlengkap yang memberikan kalian keuntungan besar dengan semua yang dibutuhkan oleh para pemain. Jadi, bermainlah di situs bandar togel Asia Coloktoto.

    ReplyDelete
  39. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
    top online electronics shopping sites in india

    ReplyDelete
  40. I always like to read a quality content having accurate information regarding the subject and the same thing I found in this post.

    Website Development Company |

    ReplyDelete
  41. Great information, i was searching of this kind of information, thank you very much for sharing with us.

    Website : Craigslist Posting Service for Car Dealers |

    ReplyDelete
  42. This is really amazing website that I have been found on google regarding website Blog Commenting sites. and I would like to thank admin who also given us to post the link on his side.

    Lubbock moving company |

    ReplyDelete
  43. This was something I was looking for, really helpful, and great work is done. Thank you so much for sharing such valuable information.

    Car Auction Software |

    ReplyDelete
  44. It’s really a cool and helpful piece of information. I am glad that you shared useful information with us. Please keep us up to date like this. Thanks for sharing.

    Best CRM for Small Businesses |

    ReplyDelete
  45. I am really like it very much for the interesting info in this blog that to this website is providing the wonderful info in this blog that to utilize the great technology in this blog.

    Web Development Company in Gwalior |

    ReplyDelete
  46. web developer, This was incredibly an exquisite implementation of your ideas, and if you need then come visit us!

    ReplyDelete
  47. Tekniko Global is an award-winning mobile app development company in Delhi and other city or countries. We develop high-quality.

    ReplyDelete
  48. Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! New York Custom Website Design

    ReplyDelete
  49. I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site.
    Data Science Training in Chennai

    ReplyDelete
  50. Hey Wonderful information, Thanks a lot sharing kind of information. Your website gives the best and the most interesting information. Free Astrology consultation on phone

    ReplyDelete
  51. Good. I am really impressed with your writing talents and also with the layout on your weblog. Appreciate, Is this a paid subject matter or did you customize it yourself? Either way keep up the nice quality writing, it is rare to peer a nice weblog like this one nowadays. Thank you, check also virtual edge and thank you for speaking at our event

    ReplyDelete
  52. Thank you very much for writing this blog. It was very easy to understand.

    Marriage Garden in Gwalior |

    ReplyDelete
  53. I always like to read a quality content having accurate information regarding the subject and the same thing I found in this post.
    Web Development Company in Gwalior |

    ReplyDelete
  54. I am really like it very much for the interesting info in this blog that to this website is providing the wonderful info in this blog that to utilize the great technology in this blog.
    Website Development Company in Gwalior |

    ReplyDelete
  55. It’s really a cool and helpful piece of information. I am glad that you shared useful information with us. Please keep us up to date like this. Thanks for sharing.
    Best CRM for Small Businesses |

    ReplyDelete
  56. This was something I was looking for, really helpful, and great work is done. Thank you so much for sharing such valuable information.
    Car Auction Software |

    ReplyDelete
  57. This is really amazing website that I have been found on google regarding website Blog Commenting sites. and I would like to thank admin who also given us to post the link on his side.
    Lubbock moving company |

    ReplyDelete
  58. Great information, i was searching of this kind of information, thank you very much for sharing with us.
    Craigslist Posting Service for Car Dealers |

    ReplyDelete