I am working on a project and want to get questions from stack overflow using Stack Overflow API. I searched the way how to achieve the same here:
Assuming that you have registered your application.
Go to Manage your applications from here http://stackapps.com/apps/oauth
Enable Client side flow within App settings.
Now as you want to create Desktop application, following are steps:
First you need to get Access Token by redirecting user to this link: https://stackexchange.com/oauth/dialog?client_id=[YOUR_APP_ID]&scope=private_info&redirect_uri=https://stackexchange.com/oauth/login_success
You (as a user) will approve the request made by the application. Then you will be redirected to another link in which there will be an access_token.
Grab the access token from there and put it in this link :
This will be your ready API.
Get content using:
$context = stream_context_create(array('https' => array('header'=>'Connection: close\r\n'))); $json_array = file_get_contents("YOUR_API_URL", false, $context); $data = json_decode(gzdecode($json_array),true); print_r($data); // Show your file data
The data you will get is in JSON and is compressed (in GZIP from). So we decompressed it and then decoded JSON.
This should work. It worked for me. :)