0

Hmmm. Some of the examples don't seem to work for me:

// Initialize cURL to send a GET request and return the response as a string 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

// Fetch everything about Dani from her profile 
curl_setopt($ch, CURLOPT_URL, 
    urlencode('http://www.daniweb.com/api/entity/Username/diafol')); 

// Receive and subsequently decode the response from JSON into a PHP array 
$output = json_decode(curl_exec($ch), true); 

// Close the cURL request 
curl_close($ch); 

// Print out the resulting PHP multi-dimensional associative array 
var_dump($output); 
?>



<?php 
//$myNum set 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

// Fetch the second page of upvoted posts by Dani 
curl_setopt($ch, CURLOPT_URL, 
    urlencode("http://www.daniweb.com/api/posts/Member/$myNum/upvoted/2")); 

$output = json_decode(curl_exec($ch), true); 
curl_close($ch); 
var_dump($output); 
?>

I just get NULL. THe rss code works though.

0

I used '1' (as in the doc), so I assumed this referred to the member number. I tried a few different ones, to no avail.

$myNum = 1 etc

so I didn't have to wade through and hard code every time.

Is the API (the snippets I included) working for you? None of the json/gets seem to work for me. :(

Edited by diafol

0

SOrry about that. It was a typo in my examples that I was wrapping the URL being passed into cURL with urlencode().

0

I can certainly see the benefit of software that lets you post on your own terms (if you don't like the DaniWeb editor, for example)

You caught me quick :P

But yes, I understand the security issues a writing ability would cause...

0

Yes, I said it ... we'll have write functionality.

YES! :D

Expect a desktop client from me soon :P

0

Full OAuth for the win :) Now you can write 'Login with DaniWeb' applications the same way there's Log In with Facebook.

Let's see how many developers out there want to leverage our one million members!

1

For the C# users in this thread, all you need to do is use RestSharp. It will handle the API rather nicely. Here is some sample code to use the WhoAmI method:

var accessToken = "use the documentation to learn how to get this";
var client = new RestClient("http://www.daniweb.com/api");
var request = new RestRequest("me", Method.POST);
request.AddParameter("access_token", accessToken);
var response = client.Execute(request);
0

Would it be possible to include sections on different languages pHp, c# etc in the documentation as they become available? May save people from having to reinvent the wheel?

1

I was just about to start a new thread asking if people could post ports of my demo in different languages in our code snippet library, and I'll link to them all from within the documentation.

1

So I have an idea for an app: What about writing a little page where it shows you the top members you recently had communication with?

0

When you vote with a comment, lots of things happen: You affect someone's reputation, you send an email to the poster, etc.

In the interests of having all write queries be as innocuous as possible right now, I've opted to not provide an easy way for someone to write a bot capable of trolling and emailing a million members.

The idea is the API currently has fully functional read capability, plus the ability to quickly vote on or watch posts you might stumble across, which is an ideal feature set IMHO for a mobile application (hint hint).

0

At one point in time (did you perhaps Donate to the site?) you had the ability to set a custom user title, and you chose Postaholic.

However, your member profile currently doesn't have the privilege of custom user titles, and therefore the site is displaying the generic one.

Should your member permissions ever change, the custom user title is waiting for you in the database.

Disclaimer: We no longer offer custom user titles to sponsors. Now you must be a moderator or someone special.

0

I can't remember that I've ever had the ability to change it. And if I've had the ability at some point in time, I can assure you that I never made a change to my user title.

0

Oh, you know what I think happened. I think when we switched platforms, the current user titles were migrated over to the database regardless of whether they were custom or not.

1

Q: In my fiddling with things, is there a way of retrieving multiple users' data as json in one call? It's reaaally slow with say 8 calls in succession.

Votes + Comments
Good question.
0

I'm not home now, but when I get home (or tomorrow) I'll look into this.

0

Lots of work happening right now on speed as well.

Also, I'm going to be changing the design of the API docs shortly. Everything will stay the same, just the documentation is being reorganized.

0

I like the idea of the API, and the page for it... all i know to do is use it at one point! Nice job dani!

0

Thanks! I'm spending a lot of time on it, trying to make (at least the read functionality) as robust and concise as possible.

0

For the C# users in this thread, all you need to do is use RestSharp. It will handle the API rather nicely. Here is some sample code to use the WhoAmI method:

var accessToken = "use the documentation to learn how to get this";

Mind setting a example on how to aquire the accesstoken in C#?

0

BTW - the file_get_contents() works for me, but I know certain hosts don't allow this, so cURL may be the only option for them. Does the documentation need to reflect this, or do you think that's up to the user to figure out?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.