Creating a jsonp wrapper for json data

I tried to solve this for a long time and now I know why this is impossible. URL

http://twittercounter.com/api/?username=Anand_Dasgupta&output=json&results=3

returns json, but when I add "& callback = get" along with it, it does not indicate the callback wrapper function.

Thus, the only solution now is to manually create a wrapper around json data.

My question is how I do it. Is there some kind of code already existing in php / javascript that I can change according to my specifications.

Any advice would be appreciated.

thanks

Anand

+3
source share
1 answer

, JSONP - JSON ( JavaScript ) , , . JavaScript. ( JSONP), URL-, script.

, PHP, , - script. script URL- :

<?php
    // Don't know on the fly how to request data from another URL in PHP, but it easy to find out
    $response = request_url('http://twittercounter.com/api/?username=Anand%5FDasgupta&output=json&results=3');
    echo $_GET['callback'] . '(' . $response . ')';
?>
+3

Source: https://habr.com/ru/post/1711747/


All Articles