AnsweredAssumed Answered

PHP cross-domain request to PI WEB API

Question asked by eat_k on Sep 18, 2017
Latest reply on Sep 20, 2017 by eat_k



I am looking for a way to make requests to PI WEB API from PHP in the following environment :


- I have PI WEB API installed and running in domain-A, with Kerberos Authentication enabled

- I have an apache server in domain-B, on which on php website is running on.

- Users log into the website using an existing account from domain-B, the server-side php code would use curl to make requests to the PI WEB API in domain-A


After searching around for a white, I could not find a way to make this work. Those are the tests I have done so far :


- if the web server is on the same domain as PI WEB API, the following code works :


function getRequest($url) {
    $ch = curl_init($url);    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
    curl_setopt($ch, CURLOPT_USERPWD, ":");
    $result = curl_exec($ch);
    $json = json_decode($result, true);
    return $json;


- using a web browser (IE, Firefox) from a computer in domain-B works. I am also able to view the HTTP requests and responses with Fiddler, but I am not able to do the same in my php code.


I believe I should investigate the Cors (but if I am not wrong, server-side calls are not subject to Cors) and kerberos mechanics but my knowledges are limited to reading documentation and other topics. I have yet to find a way to do this in programming.


The following links are some of the hints I have tried to use thus far :


Developing a PHP application using PI Web API

Getting started with PI Web API


How to support Pi Web API "Kerberos Authentication" using nodejs/javascript?

Not authorized to view the specified discussion 1581


Now out of idea, I am looking for help in solving this.


You can ask me questions if I forgot any information.


Thanks in advance