I'm trying to implement this simple request in Drupal 7 on my local machine:
$request = drupal_http_request('https://api.stackexchange.com/2.2/users?order=desc&sort=reputation&site=stackoverflow');
$json_response = drupal_json_decode($request->data);
For your information:
- drupal_http_request() performs an HTTP request.
- drupal_json_decode() converts an HTML-safe JSON string into its PHP equivalent.
From my side, the endpoint seems to work fine, as it sends a correct JSON result with all the users.
But I still can't recover the data because it's like $request->data
appears like blank despite the "4468 characters". That's wierd.
While I'm supposed to get something like that, with a very beautiful JSON string:
If I try with another API, like Twitter for example, it works fine (sorry I put an old depreciated endpoint but it's not important, I get the data back anyway) :
Does someone have a clue about that strange issue? Thank you.