0

I have been asked to work with APIs. Never done so before. The remote server which I need to be pulling data from is built on Java. The API is only in Java. I have done some research and seen some workarounds which don't look so pretty. I want to see if there is any easy, straightforward way that I can call Java APIs into PHP and have PHP work with the data?

Yusof
  • 73
  • 1
  • 9
  • How does your remote server expose those Java APIs? It all depends on that. – RaviH Feb 17 '14 at 04:17
  • The API is web exposed, right ? Whether it is RESTful/not you can use Javascript and work with it. – Ahamed Mustafa M Feb 17 '14 at 04:18
  • I don't believe it. An API is an endpoint, essentially, to retrieve data from. Likely offering JSON notation as a means of being language agnostic. – Ohgodwhy Feb 17 '14 at 04:18
  • I'm not really sure, how to answer your question.. might need more details such as. (1) Do you have access to any Servlets on the Java API? (2) Do you know the current Format being pushed on request, from the Java API? (3) If you do know the format, just build a way to read said format in PHP. – classicjonesynz Feb 17 '14 at 04:18
  • @killrawr - I do not have access. What I've been reading from the documentations is that you just call functions after you provide necessary credentials. I have not played much with it. Just been researching before diving. – Yusof Feb 17 '14 at 04:24
  • I hope you are not referring to a JAR file as an "API" (Developers usually use API's to connect third party applications to an application external their server)... an API doesn't require any coding per say, you should just simply provide a URL with some parameters to get the information you require, then you could use something like `file_get_contents` or a `curl` request to handle said data on PHP. – classicjonesynz Feb 17 '14 at 04:26
  • @AhamedMustafaM - I didn't think about using JavaScript to call Java classes. This may be interesting. Ill do more research and let you know how it goes! – Yusof Feb 17 '14 at 04:30
  • @Killrawr ya...not .JAR. just API to connect to a third party server. Let me try what you said tomorrow when I am in the office. I will let you know what I find. – Yusof Feb 17 '14 at 04:33
  • @Yusof I would only recommend using JavaScript AJAX to call Java, depending on the level of data you are requesting.. for instance if you are trying to filter something like 4000+ records (AJAX is the way to go, reduce page load times).. but if is only something that is less than 100 records, then you can afford to do it server-side. – classicjonesynz Feb 17 '14 at 04:33
  • @killrawr good to know. I would have to look at AJAX then :) – Yusof Feb 17 '14 at 04:37
  • @Yusof Check out this answer, for handling data on external servers with PHP http://stackoverflow.com/questions/11572696/how-to-call-a-website-service-from-php (be sure to upvote ;)) – classicjonesynz Feb 17 '14 at 04:37
  • 1
    let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/47616/discussion-between-killrawr-and-yusof) – classicjonesynz Feb 17 '14 at 04:39

0 Answers0