Regarding REST API - rest

I'm new to REST APIs and trying to understand the basics of them. So lets begin by saying that I have created a simple CMS web application using PHP (You create an user, you post an entry and assign some categories maybe, etc...).
That being said, if I wanted to create a mobile app that would do the same, I'll have to create some PHP functions in order to send data as JSON or XML and also in order to process a POST or PUT request.
is a REST API the collection of those functions I'd use to handle the mobile app POST, PUT and GET request using JSON or XML as the data format? if not, can I get an example, not a definition, please.

To answer your question,yes, the REST API is a collection of those functions for any client you wish to expose it to for creating an user, posting an entry etc. The accepted data format is something you decide for your API. It may be JSON, XML or even both.
Some examples:
http://coenraets.org/blog/2011/12/restful-services-with-jquery-php-and-the-slim-framework/
http://peter.neish.net/building-a-mobile-app-backend-using-mongodb-and-slim-a-php-rest-framework/

Related

Magento 2 - receive XML in post data (API)

In my store, I need to build Soap API, which accepts XML data from 3rd party solution, parses it and creates new customer based on provided data.
My questions is how can I get XML from post body data?
Thanks!
Just don't. Create separate service that is going to do that using Magento framework (check Customer or Catalog module for guidance). Because your request at the moment looks like you're going wrong way.
Just capture the XML in Controller's execute function.

How to grab all the issues inside a jira structureboard using REST api

I have been researching Jira REST api in order to grab all the test cases inside my structures but I haven't had any luck. The closes I have been to getting inside a structure is using the URL $baseUrl/rest/structure/2.0/structure. From there I tried to manipulate the url into giving me all the information about a specific structure.
For example, I used $baseUrl/rest/structure/2.0/structure/$id but I only got back
{"id":135,"name":"TEST PLAN 1","description":""}
There is hardly any information in this REST api call. IS there a way to have it list out all the issue keys(test cases) in the structure i pick?
Information Regarding JIRA Structure REST API is posted here https://wiki.almworks.com/display/structure/Forest+Resource

How can one learn to use the twitter API?

Ok before you jump to some conclusion like I'm looking for a free lunch or something of the sort, read the description entirely.
I have experience only in making small simple apps in PHP, Java and ASP.NET. I had no idea what GET, SET etc exactly are and what REST services are. To try to use the Twitter API, I did some reading and got to know (I might be wrong here, because this is what I THINK that I know..) that you can make a GET request like this one:
http://api.twitter.com/1/statuses/user_timeline.json
Using, say, cURL (I haven't tried it yet), and you get a JSON object returned which contains the statuses on your timeline in a certain format. And I verified this from here
But I don't understand how does Twitter know that it is ME and return only MY data? Where am I sending my account details?
What I want is for the use to come to my website, click a button to give my application the permission to access his/her Tweets and I do some processing in PHP and display the output. But I don't know where do I start from?
I am not asking you to give me bread, I'm asking you to tell me what should I do to learn to fish?
All tutorial I have been following till now have been sort of spoon fed where they say things like 'Download this php file from our site, include it in your source file, use this method to do this and that method to do that.'
This one is a change for me, so does anyone have any pointers? Is there any reading that I should do or approach that I must follow to learn that I'm doing wrong?
EDIT : I know there are 3rd party libraries out there and it might be easier to learn to use those, but I want to have an idea of how the people who made those did it.
To use Twitter (at least its REST API), you had better to read tutorials about the following things :
REST architecture because it is how Twitter communicates with your application.
HTTP requests. Useful for Authentication of requests (HTTP headers), kinds of HTTP requests (GET and POST for the Twitter API) and return codes of requests.
OAuth which is the protocol used by Twitter for authenticating requests.
Format of datas returned by Twitter after the requests. Most of the time it is JSON but it can also be like in a URL query string (for OAuth authentications). You are lucky because before there were XML and Atom (for RSS feeds) too.
And of course the Twitter Documentation to know how they use all that stuff, how they know that is YOU with THIS application (request authentications) and to know the objects manipulated by the API (mainly tweets, users and timelines).
Good luck for it !

How do i use an API

I've never used an API and was wondering how you use them... I would like to use facebook, twitter and vimeo's api,
Can someone explain the basics of using them, how do i access them and use them etc.
Please and thanks
Neil
How to use an API depends on the API. Usually the API creator has documentation on how to use their specific API.
Mostly, things work like the following:
You register to get a developer key. Then, you send requests to the service via HTTP (for example Twitter is using REST, which requires you to send XML or JSON to a specific http-URL providing your key). You get an answer from the service, which you must then parse and react to accordingly (for example filling a list with contacts, etc.).
Most of the time this all comes down to:
Create an XML or JSON document that describes the call parameters
Send the document to an URL using GET, POST or other request methods
Get the server's response
Parse and evaluate the response
The specific ways to use the API, especially performing authentication, can be found on the service's developer pages.
The best way to start if you want to use an API is to read it's documentation, find some tutorials and code examples. This is always/usually published by the one offering an API.
Good luck :)

creating a POST request in objective-C

I have implemented a REST based web service and used it to access data back in MySQL database.
I am using this framework to access the json data http://code.google.com/p/json-framework/
I have no problems in getting the content from this web service, but how can I put something in the database? Should I just make a special query string and have the php code in the backend to interpret this special keyword/query string as an insert to the database?
You're looking for ASIHTTPRequest. You can use that for everything from dumping pages to submitting data via POST or FORM.
Have fun :)
POST is a HTTP method. Your web service should behave differently depending on the method used for the request, if you're implementing REST.
If you send a POST request, your web service should inspect the parameters and do what it needs to do.
What parameters you send and how is dependent on how you've written the web service. Ie. Is the web service expecting XML requests or JSON or URL parameters?