1

I have a PHP project which accesses an API. the project works perfectly well using the test uri for the API.

When I started using the live uri I started getting authentication errors.

After asking around and eventually finding complete documentation, I found out that the Authentication Token needs to be passed as an Http request header. The token is generated by a C# class

Short of rewriting the project in C# is there a way of making the class and it's functions available in the PHP project?

Sarah Richardson
  • 833
  • 2
  • 10
  • 22
  • 1
    Compile the class into an Assembly then: http://php.net/manual/en/class.dotnet.php (Assuming Windows) – Alex K. Sep 19 '17 at 14:26
  • See https://social.msdn.microsoft.com/Forums/vstudio/en-US/0ab0c2ef-ff20-4044-9edc-8836d32e0e0f/instantiate-c-class-in-php?forum=csharpgeneral – PaulF Sep 19 '17 at 14:28
  • rewrite that one class in PHP? If the auth token is generated according to a particular algorithm (there should be a language-independent spec which defines how it must be done?) then you can just re-implement that? But are you sure this is the only way to get the auth token? It doesn't sound like a conventional implementation of a token service. – ADyson Sep 19 '17 at 14:46
  • Take a look at this question: https://stackoverflow.com/questions/1110682/extending-php-with-c It stands to reason that if you make a C++/CLI wrapper for this C# class you could utilize this question's answer. – DeathByTensors Sep 19 '17 at 15:28

0 Answers0