Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

How to use Traff API

for workshop on Feb 11, 2011
by

nattapon klakhaeng

on 10 February 2011

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of How to use Traff API

How to use Traffy API. Traffy's Developer Account
Understand Access Method
APP ID Check your self http://api.traffy.in.th Activation Account Fill out your
information click here Fill out Pin Code If not recive sms pin code Create Account Complete Create an Account Access Traffy API Traffy API is Provider Requester [http://www.someurl.com + parameter] Request [xml, json, csv, image] REST Web Services Response API Address http://api.traffy.in.th/apis/apitraffy.php ?api=[api name]
&format=[format]
&appid=[appid]
&key=[key]
&... Main Parameter api : specify service.
format : specify data format
appid: id from registration your application
key: secret key from registered appid Create Application ID (APP ID) APPID TYPE I. Web Referrer II . Server IP III. Session Key display image
create web with javascript
Recommend Required web address How to create? I. Login II. Click Add III. Select APP Type IV. Fills out V. click "OK" http://api.traffy.in.th click here ! III. Select APPID type as "Website" IV . Insert your website url !! IV. Fill out an information V. Click !! Example <img src="http://api.traffy.in.th/apis/apitraffy.php? api=getcctvimg& format=jpg& appid=[ your app id ]& key=[your key] > show cctv image select jpg format use registered appid and key HTML ONE TAG The APPID and the URL must match the registered otherwise it will not be able to get traffic data. Note fixed ip address Required The APPID with the IP must match the registered otherwise it will not be able to get traffic data. Recommend Note sync data.
create dynamic website
Ex. php, jsp, asp etc. Example <?php
$url = "http://api.traffy.in.th/apis/apitraffy.php?
api=getIncident&format=XML
&key=XXX&appid=0000009X";
$web = fopen($url,'r');
$xml = stream_get_contents($web);
echo $xml;
fclose($web);
?>
V. Click !! IV. Fill out an information III. Select APPID type as "Server IP" IV . Insert your ip address !! Required Concept understand idea Mobile APP
Desktop APP Recommend Session key is valid until mid night of created day. Note 1. Create random string.
-Use appid to get random string on http://api.traffy.in.th/apis/getKey.php?appid=[app id] . 2. Create session key.
- 1 = md5( APPID+Randomstring )
- 2 = md5( Key+Randomstring )
-session key = 1 +2 3. Access data with session key. <?php
// 1 random string
$appid= 'XXXXXXXX';
$key = 'XXXXXXXXX';
$getStringURL = "http://api.traffy.in.th/apis/getKey.php?appid=$appid";
$web = fopen($getStringURL,'r');
$randomString = stream_get_contents($web); //3. access data
$service = "http://api.traffy.in.th/apis/apitraffy.php"; $r=fopen("$service?api=getLinkALLInfo
&appid=$appid&
&format=XML","r");
$response= stream_get_contents($r);
echo $response;
fclose($web);
fclose($r);
?> // 2 session key
$part1 = md5($appid.$randomString);
$part2 = md5($key.$randomString);
$sessionKey = $part1.$part2; Example III. Select APPID type as "Session" IV. Fill out an information V. Click !! Traffy's Manual http://info.traffy.in.th Q&A your appid & key PHP Code show traffic incident
in xml format Your App Id and key key=$sessionKey What is Traffy APIs? Work Shop 1#. create appid for web referrer step 1. create appid and key Work Shop 2#. create appid for Server IP open editor ( notepad )
type code
save as workshop1.html step 2. step 2. open editor ( notepad )
type code
save as workshop2.php Move your file to Appserv Folder
run your script step 3. C:/Appserv/www/ C:/Apache/htdoc/ http://localhost/workshop1.html http://localhost/workshop2.html Error !! add your appid with this ip address Summary Authenticate Authenticate Authenticate
Full transcript