We are in the modern era of technologies and on the verge of
new evolutions on mobile and internet world. Every day technologies are
stepping towards achievements of fantcies and taking the world to our
fingertips.
PDA’s are now been widely used across the world. We are now
wel comfortable with the usage of Smartphone’s for internet browsing, mail
access etc.
Smartphone’s are now with well equipped configurations but
there are still some limitations on processor speeds, web access speeds etc.
Drupal web services could be the ray of light allowing PDA
users to have access to the websites, databases etc on their devices.
Web services get synchronized with the web servers, fetch
the required data and show it to the users.
Web Services example for iphone
Iphone access information using php web services. first Create php file to send information to iphone.
Send information in array using json_ encode.
$host = "";
$db = "database_name "; // database name
$uid = "user_name"; // database user name
$pwd = " pass_word"; // database password
$link = mysql_connect($host, $uid, $pwd); // connect database using mysql connect function
mysql_select_db($db) or die("Could not select database");
$arr = array();
$name= $_REQUEST['name']; // get request from iphone
// get information from database and store values and object in array
$db = "database_name "; // database name
$uid = "user_name"; // database user name
$pwd = " pass_word"; // database password
$link = mysql_connect($host, $uid, $pwd); // connect database using mysql connect function
mysql_select_db($db) or die("Could not select database");
$arr = array();
$name= $_REQUEST['name']; // get request from iphone
// get information from database and store values and object in array
$rs = mysql_query("select name,password from users where name=%d ",$name);
while($obj = mysql_fetch_object($rs))
{
$arr[] = $obj; // store object in array
}
// following line is very important to send information to Iphone
// iphone access information using user_info
echo ('{"user_info":'.json_encode($arr).'}');
?>
Output is
{"user_info": {"name": "sam", "password": "sam!1"}}
Drupal Web services
Services comes with XMLRPC server, other servers such as JSON, REST, SOAP, and AMF can be
Downloaded from the above link. Service API allows modules to create other services.
Following Services are provided
1) Comment
2) File
3) Menu
4) Node
5) Search
6) User
7) Views
8) Taxonomy
Setup your Key Authentication & method access for domain
Path is admin/build/services/keys/add
For Example
if access node content then use following method’s
Nid is required for all node method to get information and return array of node
1) Node.get
2) Node.view
3) Node.save
4) Node.delete
No comments:
Post a Comment