a_pixel

API systemu Sugester

API sugestera realizowane jest przez REST (JSON lub XML)

nowy opis api znajduje się na stronie https://github.com/sugester/API

Po zalogowaniu się do Sugester w menu Ustawienie > API znajdują się przykłady działające na danym koncie. Są one też dostępne na stronie https://api.sugester.pl

Autentykacja

Każde zapytanie musi zawierać autentykację za pomocą loginu i hasła użytkownika. Dodatkowo url musi odwoływać się do wybranego forum sugestii np. https://TWOJE_FORUM.sugester.pl. Przykład:


  
	curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u TWOJ_LOGIN:TWOJE_HASLO \
	     https://sugester.sugester.pl/app/users/me.xml
					

Parametry

Parametry mogą być przekazywane przez XML (wymagane dla POST):

  
  
	curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u TWOJ_LOGIN:TWOJE_HASLO \
	     http://sugester.sugester.pl/ -d '<order>rejected</order>'
		

 

lub w URL-u:

 

  
  
	curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u TWOJ_LOGIN:TWOJE_HASLO \
	     http://sugester.sugester.pl/?order=rejected'
		

Użytkownicy

Pobranie Twoich danych

GET http://NAZWA_FORUM.sugester.pl/app/users/me.xml

wynik:


	
	 <user>
	  <created-at type="datetime">2009-01-26T18:06:53+01:00</created-at>
	  <description>administrator sugestera...</description>
	  <email>email@email.pl</email>
	  <login>sugester</login>
	  <name>Sugester</name>
	  <notification>all</notification>
	  <updated-at type="datetime">2009-02-02T00:34:02+01:00</updated-at>
	  <www>www.sugester.pl</www>
	</user>
	

 

 

Pobranie listy współpracowników

 

 

GET http://NAZWA_FORUM.sugester.pl/app/users/team.xml

wynik:


  
	
	<users type="array">
	  <user>
		  <created-at type="datetime">2009-01-26T18:06:53+01:00</created-at>
		  <description>administrator sugestera...</description>
		  <email>email@email.pl</email>
		  <login>sugester</login>
		  <name>Sugester</name>
		  <notification>all</notification>
		  <updated-at type="datetime">2009-02-02T00:34:02+01:00</updated-at>
		  <www>www.sugester.pl</www>
	  </user>
	  <user>
		  <created-at type="datetime">2009-01-26T18:06:53+01:00</created-at>
		  <description>administrator sugestera...</description>
		  <email>email2@email.pl</email>
		  <login>sugester2</login>
		  <name>Sugester</name>
		  <notification>all</notification>
		  <updated-at type="datetime">2009-02-02T00:34:02+01:00</updated-at>
		  <www>www.sugester2.pl</www>
	  </user>
	</users>
	
	

Sugestie

Pobranie listy sugestii z głównej kategorii. Parametry (order, page) można przekazywać tak jak w wersji HTML.

GET http://NAZWA_FORUM.sugester.pl/ - kategoria pierwsza
GET http://NAZWA_FORUM.sugester.pl/NAZWA_KATEGORII - wybrana kategoria
GET http://NAZWA_FORUM.sugester.pl/?order=new&page=2 - przykład parametryzacji

wynik:


	
	<posts type="array">
	 <post>
	    <agent>Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2</agent>
	    <comments-cache type="integer">0</comments-cache>
	    <content>tak aby by&#322;a podobna do strony / produktu kt&#243;rej dotyczy </content>
	    <created-at type="datetime">2009-08-17T00:26:10+02:00</created-at>
	    <id type="integer">10464</id>
	    <title>zmiana wygl&#261;du forum sugestii i buttona</title>
	    <updated-at type="datetime">2009-09-07T13:32:49+02:00</updated-at>
	    <votes-cache type="integer">2</votes-cache>
	  </post>
	 <post>
	    <agent>Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2</agent>
	    <comments-cache type="integer">0</comments-cache>
	    <content>tak aby by&#322;a podobna do strony / produktu kt&#243;rej dotyczy22 </content>
	    <created-at type="datetime">2009-08-17T00:26:10+02:00</created-at>
	    <id type="integer">104641</id>
	    <title>zmiana wygl&#261;du forum sugestii i buttona</title>
	    <updated-at type="datetime">2009-09-07T13:32:49+02:00</updated-at>
	    <votes-cache type="integer">2</votes-cache>
	  </post>
	</posts>
	

 

 

Cats from forum

 

 

GET http://NAZWA_FORUM.sugester.pl/app/categories.xml

wynik:



	<categories type="array">
	  <category>
	    <id type="integer">1</id>
	    <name>sugestie u&#380;ytkownik&#243;w</name>
	  </category>
	  <category>
	    <id type="integer">785</id>
	    <name>nasze plany...</name>
	  </category>
	</categories>


 

 

Wyświetlenie pojedyńczej sugestii wraz z komentarzami

 

 

GET http://NAZWA_FORUM.sugester.pl/app/posts/POST_ID.xml

wynik:



	<hash>
	  <comments type="array">
	    <comment>
	      <agent>Mozilla/5.0</agent>
	      <comment>i super !!:)</comment>
	      <created-at type="datetime">2009-09-19T17:33:57+02:00</created-at>
	      <id type="integer">89011</id>
	      <kind nil="true"></kind>
	      <updated-at type="datetime">2009-09-19T17:33:57+02:00</updated-at>
	    </comment>
	    <comment>
	      <agent>Mozilla/5.0 </agent>
	      <comment>zaromb</comment>
	      <created-at type="datetime">2009-10-12T17:08:17+02:00</created-at>
	      <id type="integer">89654</id>
	      <kind nil="true"></kind>
	      <updated-at type="datetime">2009-10-12T17:08:17+02:00</updated-at>
	    </comment>
	    <comment>
	      <agent>Mozilla/5.0 </agent>
	      <comment>i to taz</comment>
	      <created-at type="datetime">2009-10-12T17:12:42+02:00</created-at>
	      <id type="integer">89656</id>
	      <kind nil="true"></kind>
	      <updated-at type="datetime">2009-10-12T17:12:42+02:00</updated-at>
	    </comment>
	  </comments>
	  <post>
	    <agent>Mozilla/5.0</agent>
	    <category-id type="integer">1</category-id>
	    <comments-cache type="integer">3</comments-cache>
	    <content>Powinno tez by&#263; SPA i tam cy by&#322;y maseczki , gor&#261;ce &#380;r&#243;d&#322;a , ora i to by 
			podwy&#380;sza&#322;o energie</content>
	    <created-at type="datetime">2009-09-10T19:01:53+02:00</created-at>
	    <id type="integer">12934</id>
	    <kind>suggestion</kind>
	    <responsible-id type="integer" nil="true"></responsible-id>
	    <status>new</status>
	    <title>SPA</title>
	    <updated-at type="datetime">2009-11-13T19:06:41+01:00</updated-at>
	    <votes-cache type="integer">5</votes-cache>
	  </post>
	</hash>


 

 

Dodawanie postu

 

 

POST http://NAZWA_FORUM.sugester.pl/app/posts.xml
 

przykład wywołania:



	curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u LOGIN:HASLO
	  http://sugester.sugester.pl/app/posts 
	  -d '<post><title>temat sugestii</title><content>tresc sugestii</content></post>'



wynik:



	<post>
	  <agent>curl/7.16.1 (i386-apple-darwin8.11.1) libcurl/7.16.1 OpenSSL/0.9.8e zlib/1.2.3</agent>
	  <category-id type="integer">1</category-id>
	  <comments-cache type="integer">0</comments-cache>
	  <content>tresc sugestii</content>
	  <created-at type="datetime">2009-01-05T23:12:02+01:00</created-at>
	  <id type="integer">20871</id>
	  <kind>suggestion</kind>
	  <responsible-id type="integer" nil="true"></responsible-id>
	  <status>new</status>
	  <title>temat sugestii</title>
	  <updated-at type="datetime">2009-01-05T23:12:02+01:00</updated-at>
	  <votes-cache type="integer">0</votes-cache>
	</post>

 

 

Wykasowanie postu

 

 

DELETE http://NAZWA_FORUM.sugester.pl/app/posts/POST_ID.xml
 

 

 

 

 

Dodanie użytkownika

 

 

 

 

POST http://NAZWA_FORUM.sugester.pl/app/users.xml
 



	curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u LOGIN:HASLO
	  http://sugester.sugester.pl/app/users.xml 
	  -d '<user><login>login1</login><email>email1@sugester.pl</email><password>password1</password></user>'

Masz pytania? Kliknij - oddzwonimy
do Ciebie w 30 sekund.