Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Good tutorial on writing APIs (internal and external) in PHP

Good tutorial on writing APIs (internal and external) in PHP

Scheduled Pinned Locked Moved Web Development
tutorialphpdesignjsonhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    malvik
    wrote on last edited by
    #1

    Hi All, I just spent an overwhelming morning trying to read up on how to write a good API to a website's service(s). For example, I want to write an API for my site's search feature that can be used within my site itself and can also be integrated with search functionality on my second website on another domain. I understand it is a restful api and am trying to find a tutorial other than gen x design that will show me how to write a good internal API that can be extended to be external too. Anyone faced this before or anticipates to face it in the future? Please help. --MM

    J 1 Reply Last reply
    0
    • M malvik

      Hi All, I just spent an overwhelming morning trying to read up on how to write a good API to a website's service(s). For example, I want to write an API for my site's search feature that can be used within my site itself and can also be integrated with search functionality on my second website on another domain. I understand it is a restful api and am trying to find a tutorial other than gen x design that will show me how to write a good internal API that can be extended to be external too. Anyone faced this before or anticipates to face it in the future? Please help. --MM

      J Offline
      J Offline
      Jayapal Chandran
      wrote on last edited by
      #2

      In this case i would generate an xml file which contains the search data. you can design the structure as you like. if the request is coming from the same domain the do the normal search display if the request is from another server then use generate an xml as output which could be read by the second sites socket. you can use the Request uri to get from which site the request is from. and according to the you can have an if condition. if(REQUEST_URI==same server)query the database and display the result else generateSearchXML(query) in the generatesearchxml you set the content type as text/xml and echo the xml... to create a request you do some thing like this... "http://site1.com/search.php?q=searchstring" create a socket (fsockopen, file_get_contents) or a socket function according to the programming language

      Today's Beautiful Moments are Tomorrow's Beautiful Memories

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups