Register for your free account! | Forgot your password?

You last visited: Today at 18:38

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



api

Discussion on api within the Web Development forum part of the Coders Den category.

Closed Thread
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
api

what is the best way to read online api data (html)
ahmed1234550 is offline  
Old 02/24/2018, 10:50   #2


 
iMostLiked's Avatar
 
elite*gold: 1337
Join Date: Apr 2013
Posts: 6,480
Received Thanks: 3,190
What type of data is the api returning? JSON or plain html?
If it's plain html you could do something like this in php:
Code:
$dom = new DOMDocument();
$dom->loadHTML(file_get_contents($url));

foreach($dom->getElementsByTagName('tr') as $node) { ... }


If it's json then:
Code:
$result = json_decode(file_get_contents($url));
echo $result->{"test"};
Instead of file_get_contents you could also use .
iMostLiked is offline  
Thanks
1 User
Old 02/24/2018, 11:01   #3
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
Quote:
Originally Posted by iMostLiked View Post
What type of data is the api returning? JSON or plain html?
If it's plain html you could do something like this in php:
Code:
$dom = new DOMDocument();
$dom->loadHTML(file_get_contents($url));

foreach($dom->getElementsByTagName('tr') as $node) { ... }


If it's json then:
Code:
$result = json_decode(file_get_contents($url));
echo $result->{"test"};
Instead of file_get_contents you could also use .
its json, i wanna do it in html not php
ahmed1234550 is offline  
Old 02/24/2018, 11:51   #4


 
iMostLiked's Avatar
 
elite*gold: 1337
Join Date: Apr 2013
Posts: 6,480
Received Thanks: 3,190
Quote:
Originally Posted by ahmed1234550 View Post
its json, i wanna do it in html not php
You can't process json in html. If you don't want to do it in php you could use javascript.
iMostLiked is offline  
Thanks
1 User
Old 02/24/2018, 12:08   #5
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
Quote:
Originally Posted by iMostLiked View Post
You can't process json in html. If you don't want to do it in php you could use javascript.
ye but i can use different ways, like fetch ajax jquery p5js, all can do the job but someone told me i dont recommend jquery for api requests, im new i dont know the differents between them, thats why im asking what should i use
ahmed1234550 is offline  
Old 02/24/2018, 12:30   #6


 
iMostLiked's Avatar
 
elite*gold: 1337
Join Date: Apr 2013
Posts: 6,480
Received Thanks: 3,190
Quote:
Originally Posted by ahmed1234550 View Post
ye but i can use different ways, like fetch ajax jquery p5js, all can do the job but someone told me i dont recommend jquery for api requests, im new i dont know the differents between them, thats why im asking what should i use
It depends on what you want to do. But apart from this I'd always process api requests server sided (e.g. php) and return their output with json so that javascript can handle that.
If your goal is making a dynamic website which requests the api more than one time you have to use ajax.
If it's only one request at the beginning (when the page loads) you don't have to use javascript since php loads before the dom.
iMostLiked is offline  
Thanks
1 User
Old 03/01/2018, 13:48   #7
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
#close
ahmed1234550 is offline  
Old 03/01/2018, 15:22   #8



 
Serraniel's Avatar
 
elite*gold: 0
The Black Market: 205/1/0
Join Date: May 2010
Posts: 6,853
Received Thanks: 5,106
#Closed (on request)
Serraniel is offline  
Closed Thread


Similar Threads Similar Threads
Public War Rock Stats API / Öffentliche War Rock Stats API
10/16/2013 - WarRock - 11 Replies
Hallo, hier eine Kleinigkeit die ihr für euren Clan benutzen könnt: http://wa-sta.net/other/api/ Damit könnt ihr z.B. auf eurer Clanseite einbinden, ob eure Member online sind, die Statistiken von ihnen etc.
API Error Code: 100 API Error Description: Invalid parameter Error Message: redirect_
04/08/2012 - elite*gold Trading - 2 Replies
API Error Code: 100 API Error Description: Invalid parameter Error Message: redirect_uri URL is not properly formatted Das bekomme ich wenn ich ne App installiere... ich habe schon 3 Apps richtig installiert, danach kam immer das bei anderen Apps die ich installiert habe.. was heisst das? redirect_uri URL is not properly formatted
[GUIDE]Api Sheild to be against API Tools!
10/15/2011 - Metin2 PServer Guides & Strategies - 8 Replies
I got lot's of pm's from people asking me about api tool shield , so i decided to make a guide to show ya all how to get rid of the nowadays hackers in your servers ... First ... Open CONFIG of each channel , set pk_server:0 to pk_server:1 then in set adminpage_ip1 with adminpage_ip1: 192.168.2.(write yur real ip here) without quotes or space , just write it after the 192.168.2 directly like this .. example : adminpage_ip1: 192.168.2.ip And keep doing that for all CONFIG of all...
[ ALL IN ONE ] Lizenserver 7120 | API Server | API Tools
07/07/2011 - Metin2 PServer Guides & Strategies - 45 Replies
Hallo @all ServerAdmins! Hier möchte ich euch ein Projekt von mir vorstellen der vieles einfacher macht. Was ist das? Ein Arbeitsplatz für Administratoren von Mt2 Server. Was kann es? behebt das Problem socket_connect: HOST 220.95.239.40:7120, could not connect.
[HELP] Api tool v2 and other api's
05/28/2011 - Metin2 Private Server - 0 Replies
Hi, can someone tell me where i can find the api tool v2 fix? and if there are other types of API tools Thank you very much



All times are GMT +1. The time now is 18:39.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.