Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Getting JSON result from Server
Old 10-01-2010, 03:26 PM Getting JSON result from Server
Junior Talker

Posts: 1
Name: zuhayr
Trades: 0
Hi All
Just joined this forum.. hope to get quick responses from here. Would like to help others too..

Problem:

There is a file on a 3rd party server, and if you visit that link with few parameters after the link, it results in JSON format. EG:

Link: api.facebook.com?name=zuhair&age=25

when i visit this i am taken to a page where it has some text result in JSON format.

Is there any way that i can get this JSON result without visiting the link manually, through some php or java script.

Searching on google yields that there is somthing call JSON callback method which fulfils this requirement.

Thanks alot in advance.
zuhayr is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-01-2010, 04:05 PM Re: Getting JSON result from Server
Ultra Talker

Posts: 366
Name: Steve
Location: Miami, FL, Earth
Trades: 0
PHP Code:
<?php

$json 
file_get_contents("http://api.facebook.com?name=zuhair&age=25");
$data json_decode($json);
print_r($data);

?>
__________________
- Steve

President,
Please login or register to view this content. Registration is FREE
smoseley is offline
Reply With Quote
View Public Profile Visit smoseley's homepage!
 
Old 10-08-2010, 05:41 AM Re: Getting JSON result from Server
lastnico's Avatar
Novice Talker

Posts: 5
Name: Nicolas Ternisien
Trades: 0
Note that you could get data from a third party website with Javascript, because it could create DDOS bomb in case of XSS or else. There are some hacks indeed to do this (see http://en.wikipedia.org/wiki/Same_origin_policy for more info)
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
lastnico is offline
Reply With Quote
View Public Profile
 
Old 10-08-2010, 07:51 AM Re: Getting JSON result from Server
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
You could also use Curl or an ajax request
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 10-08-2010, 08:08 AM Re: Getting JSON result from Server
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
+1 for smoseley's response.

Id personally do it that way.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Reply     « Reply to Getting JSON result from Server
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15155 seconds with 12 queries