0


I'm trying to develop a web-app with Producteev APIs using PHP+jQuery.
As shown in the above image, the official documentation says that you have to handle the call to the given link. Source > https://www.producteev.com/api/doc/#AuthenticationOAuth20Flows

enter image description here

So, using PHP and jQuery, I created an ajax request with type GET but the answer, when Producteev redirected the user to the correct Reditect URI, was

enter image description here

So I tried using dataType: jsonp and crossDomain: true as parameters in the ajax call, in my request as a solution, but as said in the documentation, the Producteev server answers a json.
I tried another solution, that's putting the code header("Access-Control-Allow-Origin: *"); in my PHP, at the top of the index.php page, but nothing changed.

Can someone help me figuring out a solution? Thanks a lot.

operator
  • 247
  • 1
  • 3
  • 15
  • 1
    If the API does not respond with CORS headers then you cannot make a request to it through JS code. What you are attempting to do is not possible. You will have to make the request server side. – Rory McCrossan Jan 20 '17 at 15:01
  • If you Google the issue the API vendor has been asked about this before. Their solution was to proxy the requests from JS to your own server, then on to Producteev: https://community.jivesoftware.com/thread/273068 – Rory McCrossan Jan 20 '17 at 15:03
  • _“I tried another solution, that's putting the code header("Access-Control-Allow-Origin: *"); in my PHP, at the top of the index.php page, but nothing changed”_ – of course not. The _remote_ party that you want to request data _from_ has to issue this header, they are the ones to decide whether your page is allowed to access their data cross-domain, not you. – CBroe Jan 20 '17 at 15:03
  • Google CORS or Access-Control-Allow-Origins. The headers have to be added server side. See https://www.moesif.com/blog/technical/cors/Authoritative-Guide-to-CORS-Cross-Origin-Resource-Sharing-for-REST-APIs/ – Derrick Jan 20 '17 at 23:09

0 Answers0