際際滷

際際滷Share a Scribd company logo
Server side API
               Hem Kr. Shrestha
Semicolon Developers Network Pvt. Ltd
         Email: hereshem@gmail.com
                   Date: 5th Jan, 2013
   Server-side refers to operations that are
    performed by the server in a clientserver
    relationship in computer networking..
   Application Program Interface
   An interface by software components to
    communicate with each other
   A set of routines, protocols, and tools for
    building software applications.
   A good API makes it easier to develop a
    program by providing all the building blocks.
   JSON (JavaScript Object Notation) is a
    lightweight text-based open standard
    designed for human-readable data
    interchange...
   Easy for machines to parse and generate
   Familiar to programmers of the C-family of
    languages
   Collection of name/value pairs

   Alternative: XML
{                                         <?xml version="1.0" encoding="UTF-8" ?
    "res": "success",                      <res>success</res>
    "data": {                              <data>
      "id": "1",                            <id>1</id>
                                            <username>hem</username>
      "username": "hem",
                                            <c_fname>Hem</c_fname>
      "c_fname": "Hem",                     <c_lname>Shrestha</c_lname>
      "c_lname": "Shrestha",                <n_home>014488535</n_home>
      "n_home": "014488535",                <n_mobile>98443096958</n_mobile>
      "n_mobile": "98443096958",            <n_office>014782582</n_office>
      "n_office": "014782582",              <created>2012-12-21 05:52:03
      "created": "2012-12-21 05:52:03 pm"   pm</created>
                                           </data>
    }
}


                  More info about JSON data http://www.json.org
But before we start


Analyze your Requirements



               Note down your outputs
   Add Contact
   List Contact
   Edit Contact
   Delete Contact
Server response
                                   Success, error, page not found




Required data
Here we are using JSON data format for
contact information
Public function listContact () {

    $sql = "SELECT * FROM `contacts` ";

    $myquery = mysql_query($sql) ;

    while($rows = mysql_fetch_array($myquery)){
         $row_array['id'] = $rows['id'];
         $row_array['name'] = $rows['name'];
         $row_array['number'] = $rows['number'];
         array_push($json_array,$row_array);
    }

    $json_result['res'] = 'success';
    $json_result['data'] = $json_array;
    echo json_encode($json_result);
}
To Add Contact
http://katibajyo.com/api/contacto.php?action=add&username=username
  &c_fname=contact_firstname&c_lname=contact_lastname&n_mobile=m
  obile_number&n_home=home_number&n_office=office_number

To list Contact http://katibajyo.com/api/contacto.php?action=list

To Edit Contact
  http://katibajyo.com/api/contacto.php?action=edit&id=contact_id

To Delete contact
  http://katibajyo.com/api/contacto.php?action=delete&id=contact_id


Visit http://katibajyo.com/api/contacto.php for all available operations.
JSON Object
{
  "res": error"
}
Or
{
  "res": "success",
  "data": {
    "id": "1",
    "username": "hem",
    "c_fname": "Hem",
    "c_lname": "Shrestha",
    "n_home": "014488535",
    "n_mobile": "98443096958",
    "n_office": "014782582",
    "created": "2012-12-21 05:52:03 pm"
  }
}
Contacto server API in PHP
Contacto server API in PHP
Ad

Recommended

Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
prav068
PHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post Methods
Al-Mamun Sarkar
Database Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and Mysql
Al-Mamun Sarkar
Training in Asp.net mvc3 platform-apextgi,noida
Training in Asp.net mvc3 platform-apextgi,noida
prav068
WordPress Security - WordCamp Phoenix
WordPress Security - WordCamp Phoenix
Mark Jaquith
PHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploading
Al-Mamun Sarkar
Pemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQL
Nur Fadli Utomo
ABV_fastcontact
ABV_fastcontact
arjun rao
Creating Operational Redundancy for Effective Web Data Mining
Creating Operational Redundancy for Effective Web Data Mining
Jonathan LeBlanc
Securing and Personalizing Commerce Using Identity Data Mining
Securing and Personalizing Commerce Using Identity Data Mining
Jonathan LeBlanc
Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan Session
Nur Fadli Utomo
Expressive objects
Expressive objects
Llewellyn Falco
Indexing all the things: Building your search engine in python
Indexing all the things: Building your search engine in python
Joe Cabrera
SULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programs
SULTHAN BASHA
Web Scraping with PHP
Web Scraping with PHP
Matthew Turland
C A S Sample Php
C A S Sample Php
JH Lee
HTML5
HTML5
Brandon Byars
Secure Coding with WordPress - WordCamp SF 2008
Secure Coding with WordPress - WordCamp SF 2008
Mark Jaquith
15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
3 php forms
3 php forms
hello8421
PHP an intro -1
PHP an intro -1
Kanchilug
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
COMMON Europe
Php session 3 Important topics
Php session 3 Important topics
mohamedsaad24
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
Anuchit Chalothorn
Android App Development 06 : Network &amp; Web Services
Android App Development 06 : Network &amp; Web Services
Anuchit Chalothorn
Day03 api
Day03 api
ABDEL RAHMAN KARIM
Web Service and Mobile Integrated Day II
Web Service and Mobile Integrated Day II
Anuchit Chalothorn
Os Pruett
Os Pruett
oscon2007
Ws rest
Ws rest
patriknw
Working with web_services
Working with web_services
Lorna Mitchell

More Related Content

What's hot (15)

Creating Operational Redundancy for Effective Web Data Mining
Creating Operational Redundancy for Effective Web Data Mining
Jonathan LeBlanc
Securing and Personalizing Commerce Using Identity Data Mining
Securing and Personalizing Commerce Using Identity Data Mining
Jonathan LeBlanc
Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan Session
Nur Fadli Utomo
Expressive objects
Expressive objects
Llewellyn Falco
Indexing all the things: Building your search engine in python
Indexing all the things: Building your search engine in python
Joe Cabrera
SULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programs
SULTHAN BASHA
Web Scraping with PHP
Web Scraping with PHP
Matthew Turland
C A S Sample Php
C A S Sample Php
JH Lee
HTML5
HTML5
Brandon Byars
Secure Coding with WordPress - WordCamp SF 2008
Secure Coding with WordPress - WordCamp SF 2008
Mark Jaquith
15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
3 php forms
3 php forms
hello8421
PHP an intro -1
PHP an intro -1
Kanchilug
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
COMMON Europe
Php session 3 Important topics
Php session 3 Important topics
mohamedsaad24
Creating Operational Redundancy for Effective Web Data Mining
Creating Operational Redundancy for Effective Web Data Mining
Jonathan LeBlanc
Securing and Personalizing Commerce Using Identity Data Mining
Securing and Personalizing Commerce Using Identity Data Mining
Jonathan LeBlanc
Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan Session
Nur Fadli Utomo
Indexing all the things: Building your search engine in python
Indexing all the things: Building your search engine in python
Joe Cabrera
SULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programs
SULTHAN BASHA
Web Scraping with PHP
Web Scraping with PHP
Matthew Turland
C A S Sample Php
C A S Sample Php
JH Lee
Secure Coding with WordPress - WordCamp SF 2008
Secure Coding with WordPress - WordCamp SF 2008
Mark Jaquith
15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
3 php forms
3 php forms
hello8421
PHP an intro -1
PHP an intro -1
Kanchilug
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
COMMON Europe
Php session 3 Important topics
Php session 3 Important topics
mohamedsaad24

Similar to Contacto server API in PHP (20)

Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
Anuchit Chalothorn
Android App Development 06 : Network &amp; Web Services
Android App Development 06 : Network &amp; Web Services
Anuchit Chalothorn
Day03 api
Day03 api
ABDEL RAHMAN KARIM
Web Service and Mobile Integrated Day II
Web Service and Mobile Integrated Day II
Anuchit Chalothorn
Os Pruett
Os Pruett
oscon2007
Ws rest
Ws rest
patriknw
Working with web_services
Working with web_services
Lorna Mitchell
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect Partners
Lorna Mitchell
API Reliability Guide
API Reliability Guide
Nick DeNardis
Api Penetration Testing and web app pentesting
Api Penetration Testing and web app pentesting
<h1> hi</h1>
Create a res tful services api in php.
Create a res tful services api in php.
Adeoye Akintola
Nyss Open legislation
Nyss Open legislation
GraylinKim
Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)
Matteo Collina
CrossUI Tutorial - Advanced - CRUD
CrossUI Tutorial - Advanced - CRUD
Jack Lee
Cross-Platform Data Access for Android and iPhone
Cross-Platform Data Access for Android and iPhone
Peter Friese
Consuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHP
Zoran Jeremic
Overview of RESTful web services
Overview of RESTful web services
nbuddharaju
Webservices Workshop - september 2014
Webservices Workshop - september 2014
clairvoyantllc
Building Awesome APIs in Grails
Building Awesome APIs in Grails
clatimer
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
Anuchit Chalothorn
Android App Development 06 : Network &amp; Web Services
Android App Development 06 : Network &amp; Web Services
Anuchit Chalothorn
Web Service and Mobile Integrated Day II
Web Service and Mobile Integrated Day II
Anuchit Chalothorn
Os Pruett
Os Pruett
oscon2007
Ws rest
Ws rest
patriknw
Working with web_services
Working with web_services
Lorna Mitchell
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect Partners
Lorna Mitchell
API Reliability Guide
API Reliability Guide
Nick DeNardis
Api Penetration Testing and web app pentesting
Api Penetration Testing and web app pentesting
<h1> hi</h1>
Create a res tful services api in php.
Create a res tful services api in php.
Adeoye Akintola
Nyss Open legislation
Nyss Open legislation
GraylinKim
Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)
Matteo Collina
CrossUI Tutorial - Advanced - CRUD
CrossUI Tutorial - Advanced - CRUD
Jack Lee
Cross-Platform Data Access for Android and iPhone
Cross-Platform Data Access for Android and iPhone
Peter Friese
Consuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHP
Zoran Jeremic
Overview of RESTful web services
Overview of RESTful web services
nbuddharaju
Webservices Workshop - september 2014
Webservices Workshop - september 2014
clairvoyantllc
Building Awesome APIs in Grails
Building Awesome APIs in Grails
clatimer
Ad

Recently uploaded (20)

Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
Ad

Contacto server API in PHP

  • 1. Server side API Hem Kr. Shrestha Semicolon Developers Network Pvt. Ltd Email: hereshem@gmail.com Date: 5th Jan, 2013
  • 2. Server-side refers to operations that are performed by the server in a clientserver relationship in computer networking..
  • 3. Application Program Interface An interface by software components to communicate with each other A set of routines, protocols, and tools for building software applications. A good API makes it easier to develop a program by providing all the building blocks.
  • 4. JSON (JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange... Easy for machines to parse and generate Familiar to programmers of the C-family of languages Collection of name/value pairs Alternative: XML
  • 5. { <?xml version="1.0" encoding="UTF-8" ? "res": "success", <res>success</res> "data": { <data> "id": "1", <id>1</id> <username>hem</username> "username": "hem", <c_fname>Hem</c_fname> "c_fname": "Hem", <c_lname>Shrestha</c_lname> "c_lname": "Shrestha", <n_home>014488535</n_home> "n_home": "014488535", <n_mobile>98443096958</n_mobile> "n_mobile": "98443096958", <n_office>014782582</n_office> "n_office": "014782582", <created>2012-12-21 05:52:03 "created": "2012-12-21 05:52:03 pm" pm</created> </data> } } More info about JSON data http://www.json.org
  • 6. But before we start Analyze your Requirements Note down your outputs
  • 7. Add Contact List Contact Edit Contact Delete Contact
  • 8. Server response Success, error, page not found Required data Here we are using JSON data format for contact information
  • 9. Public function listContact () { $sql = "SELECT * FROM `contacts` "; $myquery = mysql_query($sql) ; while($rows = mysql_fetch_array($myquery)){ $row_array['id'] = $rows['id']; $row_array['name'] = $rows['name']; $row_array['number'] = $rows['number']; array_push($json_array,$row_array); } $json_result['res'] = 'success'; $json_result['data'] = $json_array; echo json_encode($json_result); }
  • 10. To Add Contact http://katibajyo.com/api/contacto.php?action=add&username=username &c_fname=contact_firstname&c_lname=contact_lastname&n_mobile=m obile_number&n_home=home_number&n_office=office_number To list Contact http://katibajyo.com/api/contacto.php?action=list To Edit Contact http://katibajyo.com/api/contacto.php?action=edit&id=contact_id To Delete contact http://katibajyo.com/api/contacto.php?action=delete&id=contact_id Visit http://katibajyo.com/api/contacto.php for all available operations.
  • 11. JSON Object { "res": error" } Or { "res": "success", "data": { "id": "1", "username": "hem", "c_fname": "Hem", "c_lname": "Shrestha", "n_home": "014488535", "n_mobile": "98443096958", "n_office": "014782582", "created": "2012-12-21 05:52:03 pm" } }