开发者

json and php news system

开发者 https://www.devze.com 2023-02-24 06:35 出处:网络
I have access to the api which generates news in json. for example for news id #9 I can get date from:

I have access to the api which generates news in json. for example for news id #9 I can get date from:

someserver.com/core/news/9

this page generates json data for the news.

H开发者_JAVA百科ow I can parse this date using jquery and make news system that will include all newses?


Using jQuery.GetJSON(): http://api.jquery.com/jQuery.getJSON/

However the API provider must support JSONP otherwise you will run into browser restrictions. (Same origin policy)


Incase you change your mind, you can also do this with php (without browser restrictions, though the server would php).

$newsID = 9;
$json = file_get_contents("someserver.com/core/news/".$newsID);
$news = json_decode($json, true);
print_r($news);
0

精彩评论

暂无评论...
验证码 换一张
取 消