1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to create my site api for access data from other site

Discussion in 'PHP' started by dineshsingh1984, Apr 19, 2015.

  1. #1
    Hi,
    I want to create a api for my site which are access the data from other sites database where this api are integrate so plz tell me a flow for creating api..........
     
    dineshsingh1984, Apr 19, 2015 IP
  2. thedark

    thedark Well-Known Member

    Messages:
    1,346
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    168
    Digital Goods:
    1
    #2
    Depending on what type of data you want to give out trough your api.

    Create an /api/ directory in your folder root. Inside, create an index.php file where you get the data you want to display, json encode it and display it right away. That's the simple way. You will find more tricks later but this will get you started.
     
    thedark, Apr 19, 2015 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    You can also consider having access-keys (which the users trying to access your data will use in the request), if you plan on having subscriptions, also in that case you do NOT want to expose the content directly on a webpage, unless the access is done with a valid token.
    Also, you might wanna include ways the users of the API can limit or specify the data received - less bandwidth-usage for both them and you.
     
    PoPSiCLe, Apr 20, 2015 IP
  4. Akshayaguna Technologies

    Akshayaguna Technologies Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    using JSON is the easiest way to develop api, create a page to take get/post request, fetch the data from the database according to GET/POST request and give to user by encoding in JSON format, the user can use the JSON data for their use
     
  5. raffahacks

    raffahacks Greenhorn

    Messages:
    35
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    20
    #5
    I'd create a subdomain or a new directory for APIs, and then create pages that receive input via GET or POST requests (in PHP accessible through $_GET[] and $_POST[] arrays) and return data using JSON

    http://php.net/manual/en/book.json.php

    Cheers!
     
    raffahacks, May 18, 2015 IP