• Facepunch API
    437 replies, posted
  • The Facepunch API is now almost ready for public consumption. I've just written up some basic documentation and had cosmic duck throw a site together for it. You can now view the documentation and use the shiny new API console at the following address: [url]http://facepun.ch[/url] Please post any bug reports or suggestions in this thread so I can keep track of them. Any improvements to the documentation are also welcome. If you're interested in developing an application based on the API, feel free to add me on Steam, and I'll be happy to answer questions regarding the API there too.
  • I think I've found a problem when using the API console itself,it just doesn't send the content of newreply's message. This was the message I tried to send in,it just didn't append anything to the post message. [quote] This is quite nice,pretty fast and the responses are lightweight compared to having to scrape everything yourself. This post was sent via the api console mainly as a test. Also,when are you going to do the api usage monitor you were talking about on waywo? [/quote] [quote] URL: [noparse]http://api.facepun.ch/?username=Jvs&password=redacted&action=newreply[/noparse] Post body: thread_id=1162943&message= [/quote] The response was of course null,and I authenticated and rated the op via the console just to check.
  • Awesome! Little bug report, the post count being returned for users is incorrect, it ignores numbers after the comma, and threads in the mass debate forum return a 500 error.
  • [QUOTE=Hey0;34653571]Awesome! Little bug report, the post count being returned for users is incorrect, it ignores numbers after the comma, and threads in the mass debate forum return a 500 error.[/QUOTE] Fixed and fixed. The Mass Debate forum doesn't have ratings, so you won't get any rating or ratingkey data for that forum and others where ratings are disabled.
  • Is this an actual API, or is it some kind of scraper? I mean the behind-the-scenes stuff.
  • [QUOTE=Jookia;34653871]Is this an actual API, or is it some kind of scraper? I mean the behind-the-scenes stuff.[/QUOTE] It's scraping and parsing data out of pages into JSON. However, the API servers are trusted by Facepunch, so requests appear to come from your address, not the API server address.
  • It's really stupid to require the user to send their user/pass every single request.
  • [QUOTE=TehWhale;34657441]It's really stupid to require the user to send their user/pass every single request.[/QUOTE] You forget about it if you make something that does it all automatically. Messy code: [url]http://pastebin.com/qf0eNuFi[/url]
  • [QUOTE=Alex_grist;34657667]You forget about it if you make something that does it all automatically. Messy code: [url]http://pastebin.com/qf0eNuFi[/url][/QUOTE] [php] // A function to check if the user is logged in. public function isLoggedin() { if (isset($_SESSION['loggedin']) && isset($_SESSION['username']) && isset($_SESSION['password']) && $_SESSION['loggedin']) { return true; } } [/php] nice encapsulation there
  • [QUOTE=swift and shift;34657686]nice encapsulation there[/QUOTE] [QUOTE=Alex_grist;34657667][B]Messy code[/B][/QUOTE]
  • [QUOTE=The freeman;34658620]I am going to guess you can't post to the News Node with the API?[/QUOTE] It's a scraper, you won't be able to do any actions that you wouldn't normally be able to do.
  • [QUOTE=ruarai;34661897]How do i run this? There is no "The Basics" link?[/QUOTE] [url]http://facepun.ch/basics.php[/url]
  • [QUOTE=TehWhale;34657441]It's really stupid to require the user to send their user/pass every single request.[/QUOTE] This is how Facepunch works, so that's what we have to do... The other option would be to generate a session key and store your username and password against that key on the API server, but then people would whine about passwords being stored...
  • [QUOTE=Hexxeh;34662652]This is how Facepunch works, so that's what we have to do... The other option would be to generate a session key and store your username and password against that key on the API server, but then people would whine about passwords being stored...[/QUOTE] aren't they stored in the logs since the api uses GET requests?
  • [QUOTE=swift and shift;34662966]aren't they stored in the logs since the api uses GET requests?[/QUOTE] Unless you enable a logging flag for your request (which isn't public, I just use it for testing), no. Edit: Gonna add an action for the event log later today hopefully.
  • Currently all thread's statuses are "new", regardless of whether or not the thread's been read. Could you change it so that read threads are old? edit; getquote and getedit return 500 errors as well.
  • [QUOTE=Hey0;34667776]Currently all thread's statuses are "new", regardless of whether or not the thread's been read. Could you change it so that read threads are old? edit; getquote and getedit return 500 errors as well.[/QUOTE] I can't reproduce those problems, can you give me examples of requests where that happens?
  • [QUOTE=Hexxeh;34669480]I can't reproduce those problems, can you give me examples of requests where that happens?[/QUOTE] Trying to quote my post above gives me a 500 error. This is the url I'm using: [code]http://api.facepun.ch/?username=Hey0&password=x&action=getquote&post_id=34667776[/code]
  • [QUOTE=Hey0;34670216]Trying to quote my post above gives me a 500 error. This is the url I'm using: [code]http://api.facepun.ch/?username=Hey0&password=x&action=getquote&post_id=34667776[/code][/QUOTE] Works for me? [code]{"quote":"[QUOTE=Hey0;34667776]Currently all thread's statuses are \"new\", regardless of whether or not the thread's been read. Could you change it so that read threads are old? edit; getquote and getedit return 500 errors as well.[\/QUOTE]"}[/code] Might be something I can't reproduce on a mod account, not sure. Pass debug=true as a parameter and let me know the error.
  • [QUOTE=Hexxeh;34670322]Works for me? Might be something I can't reproduce on a mod account, not sure. Pass debug=true as a parameter and let me know the error.[/QUOTE] [code]Notice: Undefined variable: thread_id in /var/sites/facepunch-api/reply.php on line 39 Fatal error: Call to a member function getAttribute() on a non-object in /var/sites/facepunch-api/reply.php on line 16[/code]
  • [QUOTE=Hey0;34670569]I still get the same fatal error.[/QUOTE] And now?
  • [QUOTE=Hexxeh;34670617]And now?[/QUOTE] [code]Fatal error: Call to a member function getAttribute() on a non-object in /var/sites/facepunch-api/reply.php on line 20[/code]
  • Wanna add me on Steam to continue debugging this? Might take a few more attempts. [editline]12th February 2012[/editline] All fixed, thanks Hey0!