Member Avatar

What's the current status of the API following the update to tags? For searching, can ony see: which gives the same results regardless of the query text (and the 'members' equivalent, which seems to work). Was there not a tags endpoint before? Can't remember. Anyhow, was thinking of a side project with the API, but I don't want to start if it's not working as expected. For example, as the PHP forum no longer exists, I was trying to get articles with 'PHP' in them, but got a lot of junk. Thanks.

Member Avatar

Been trying to get this to work:

$client_id = xx;
$client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$current_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

if (!isset($_REQUEST['code']))

$ch = curl_init('');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
    'code' => $_REQUEST['code'],
    'redirect_uri' => $current_url,
    'client_id' => $client_id,
    'client_secret' => $client_secret,
    'grant_type' => 'authorization_code'
$response = json_decode(curl_exec($ch));

I'm getting null for $response. The redirect is fine. The id and secret are OK - triple checked under "manage my applications". Any ideas? I'm getting return code. Client Side Auth working fine.

Unfortunately, there was never a tags endpoint, and the API has not been updated since switching to the tag-based system. While there is currently no way to filter results by tags (only forums) but this will be handled very soon. I'll try to get to it tonight or tomorrow the latest.

Diafol, in looking at the database, it seems that we are receiving your OAuth request and are generating an access token for you, but you are not exchanging the code for the access token.

I can't imagine why you are getting NULL for response. You should be getting, at least, a friendly error message :(

I copied and pasted your exact code with my client_id and client_secret and it printed out a JSON object that was correct. I then tried using a bad secret, and I received the following:

object(stdClass)#59 (2) {
  string(90) "There was an error fetching an access token. The client_id and client_secret do not match."
  object(stdClass)#60 (5) {
    string(1496) "YDiMZDkP75tlj46f3I0XoaBNIgidfiYot8NwClbXNjPx1iw5VvzSy+yB5d+xOWjkvruRK8CDp2jZBvvJyxbzV7MGdBYGPFe9WsB53Bdcy4ko+OaRmUuTGB1+nyGRHBJR4V4A7aXpzfU3sJUt9eBDcMYpRcOzOkkqH+0VGgz5KBRyY3l/ShoxFm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0pVgRSqv+cmkXbwcLortByHtG5dGrBj58fX93mvjwV3HSU0SsjjRfe41kkeybTdGhTuhzNhQCPsAzMnwZNciWawmdof7jyPNZj/lS1GTgIA55YK0258ItYHWg1SCmDDv593CK0mRtwo6tuMZTP/0RpNfemr2UgTebqmc5NGqKjm/fBkhoHfpe3b61/Dr3XW50UHjtd5Z9h386cYkCx+R/SJTGNiog7PLzYGhUPvL7w=="
    string(43) ""
    string(1) "1"
    string(3) "abc"
    string(18) "authorization_code"

I'm not sure why you are getting NULL but I can't reproduce it.

Member Avatar

Heh heh, who knows? The client-side oauth works fine though. Maybe because I'm using localhost? But I'm getting the redirect, so not sure. No worries Dani. No rush. It's an academic project just for me - just want to try out a few things.

You can now use the{:TAGS} endpoint, where {:TAGS} is a semi-colon delimited list of tags. They use OR instead of intersect.

Additionally, I've discovered tonight that you might be getting NULL back because you are using an older version of cURL, and your cURL request cannot connect over SSL. Try using http:// instead of https:// in the cURL request. Yes, it's insecure, but I'm currently looking for a workaround.

Member Avatar

Thanks Dani. a star.

Member Avatar

Hi Dani just an update. Got curl to work using http instead of https. However, file_get_contents() being very tempramental. Can't use https so using http. BUT, when I try this I get SSL error:

$output = json_decode(file_get_contents(''));

Whereas this works:

$output = json_decode(file_get_contents(''));

The direct url in browser works fine for both. I noticed a redirect to the https version on the forums with :IDS.

I'm using cURL 7.39.0 (enabled) on Win8/ PHP 5.6.3. All SSL options enabled. OpenSSL/1.0.1i. Registered transports: tcp, udp, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2

You're getting inconsistent results retrieving forums because they are sometimes cached.

When using file_get_contents, always use https (it will work).

It's just cURL requests with POST data that are not working with https right now.

Member Avatar

DId you change anything? Seems https api calls now working for me. Thanks Dani. :)

Yes, reverted back to the way things were yesterday morning (but I still don't understand why they weren't working for you yesterday morning but they are working for you now.)

Yes, reverted back to the way things were yesterday morning

That must be why Firefox was alerting me to an insecure SSL cipher and now it's back to normal.

Member Avatar

Sorry for reviving this zombie, but is the DW API still live or is it incorporated with Dazah API? I looked at the Dazah API and its all around conversations and Dazah-like stuff I will probably never use. Is there still a way of creating a webapp using DW data?

Not at this very moment, but it will be coming back shortly, mostly in the form of custom aliases to various Dazah API endpoints. Dazah's API is super duper robust in that it's capable of doing everything that the DaniWeb API did when it comes to searching/filtering/profiling members, plus much more. It's just a matter of perhaps creating a "simplified" wrapper for it that revolves around DaniWeb use cases. Outside of that, the only additional DaniWeb API endpoints that are not Dazah related are retrieving articles and posts via JSON, which will also be making a comeback.

Member Avatar

Thanks Dani.