How to send an imgur API request from an async task - android

Please as I'm a networking newbie I would love if you could dumb everything down to me.
So I am developing an android app. I have worked with APIs before, but the imgur's one is really difficult to understand. For example I am used to the kind of APIs where I paste an address into the browser and I can see the json.
Then I can save that json as a string in Java and parse it with JSONObject.
Imgur instead uses this thing called OAuth that is unlike API keys. For example if I paste this into the browser bar
https://api.imgur.com/3/gallery/album/bRpHL
I get an error. The docs say that I have to
send an authorization header with your client_id in your requests
but there is no ?api_key= like parameter. there are examples with cURL which I don't know what it is or I could implement it in an AsyncTask.
So in conclusion: I just want to get data about images in an imgur album. I have a client_id but no idea how to get the result json. Many thanks.
API docs: http://api.imgur.com/

Related

Using ktor and exposed with postgresql for my back end, how should I send my resultrows to my users?

first post.
I am building an android app and the backend (remote server) im using ktor with exposed and hitting a postgresql data base. I am just unsure upon getting my results back from queries how I should attempt to send those back to my user app on android. What would be the right way. To have the user app install exposed library and just send the query results ? format all the results to a json string and blast that? Just dont know what would be ideal.
I haven't really attempted anything yet because I was looking for a "best practices" idea.
Hi and welcome to Stackoverflow.
There is no one "best practice" way to send the data from the server to the client. Noramlly it depends on your use case. However, one common way that I would suggest you use is to create RESTful-API.
This means:
Requests and Responses to/from the server will be serialized to JSON.
Confirm to HTTP verbs semantics (use GET to read data, PUT to update, etc).
Use status code for error handling
Follow the REST API guidelines for best practices (API versioning, end point names, pagination, etc)
To read more about REST API guidelines, this page is useful.
For Ktor, this will mean having a serializer, and then defining your routes. This guide is useful for Ktor.
Although this is not the only way, but it will provide you with enough experience to explore others APIs (Custom API, RPC, SOAP, etc).

how to get JSON of WIX web site data

I want to make an Android and iOS app for a site dsstrucks.com
The thing is i am not able to get the JSON data of the site. Is there a way by which i can get JSON of WIX Site so that i can use it to create an App.
I want a way by which i can get all latest updates also, just like the woocommerce rest api. Or is there a way i can create my own API for this ?
I have tried POST MAN to check GET requests and still no luck. Any minor or major help would be great full.
Thank in Advance

How does android retrieve data from a website?

I'm new to android, I'm trying to build an android app that is a front for a web portal. For example, Airbnb. They have a website, but they also have an android app that, using it's own layout, will show listings from their website.
There are many websites that teach how to or even directly convert your website to android apps. However, this will result in an app that loads too slowly and is unresponsive due to CPU usage.
Could anyone share any tutorial/guide to learn how to do this myself?
Million thanks.
To actually load data from a web server you're gonna need and API which usually delivers the proper date using JSON or XML format so that you can properly parse and display that data. Building this API is in it self a complete course on its own.
But connecting to and requesting data from the API is usually done using some networking libraries. These are some of the better know libraries for this purpose.
OkHttp: A complete library with a set of tools for handling network connections and HTTP requests.
RetroFit:Type-safe HTTP client for Android and Java by Square, Inc. which is built on top of OkHttp.
Async-Http-Client:
The Async Http Client library's purpose is to allow Java applications
to easily execute HTTP requests and asynchronously process the HTTP
responses. The library also supports the WebSocket Protocol. The Async
HTTP Client library is simple to use.
There tons of other good libraries.
its called webservices
Through android you get data in form of json from a web server and then return in custom view as you want.
Follow this link hope it will help
Step by Step Method to Access Webservice from Android
you would have to write an API/Web service or use if already exits to fetch data from web server. Basically the concept is that, the website itself must be pulling data from some database, so write an API which would fetch the data from same API and return JSON data and consume the API from your android app.
If you know PHP refere to this for the help :http://www.codeproject.com/Articles/267023/Send-and-receive-json-between-android-and-php
You can write WebService, in programming it generally refers to a web page(ex. Airbnb), that can be called from your android application which can pass in data to it, or receive data from it.
WebService is basically like a 'method' or 'function' in a normal programming language; except you're calling it over the internet.
The first thing is you have to create a Web Service. The Web Service will be your "bridge" to consume the data from other Website like airbnb or others and return the data to your android through json format for example.
You can create a Web Service using many languages like C#, Java, PHP, etc. I would like to recommend you to use the language that you know the most.
You can try to google this
Cheers

Android development: Getting data from WordPress

I'm making an android app for displaying some school events(Title of the event and a posted picture of the event).
The only thing I need for the app is getting data(String for title, ImageView for the picture)from a server.
The answer of this post, Android Development : Getting data from the web, seems to be the easiest and the most straight forward way I could find.
"The easiest way to display posts into an Android application will be
to use JSON data on the web, and read it into a Master Detail Android
application.
On the website side, getting the data to display in JSON seems to be
the most difficult part of your problem. It would be easy if it was a
Wordpress site, as there are plugins that will do this for you.
On the application side, getting the data and parsing it into a master
detail flow is a fairly trivial task."
I know almost nothing about database, networking, wordpress, and JSON. :(
I have made an wordpress account and install the JSON plugin and wordpress web server plugin. But that's how far I could get :(
My idea is
in the wordpress blog site: make a post for each new event. The title of the post is the event title and the content of the post just a picture, which is a post about the event.
in the app side: add a synchronize task within the onCreate function, so when the app is opened, it will check if there's any new post in the blog. If there's any, it will get the blog title and add to the listView, and get the picture inside of the blog and create a new layout in which has a ImageView for holding the picture.
As I said, I know nothing about web service and networking.
I have no clue about how to check if there's any new post in the blog comparing with those events already in the app.....
These two examples are the closet I could get.
http://android.programmerguru.com/android-webservice-example/
http://wordpress.org/support/topic/phonegap-android-app-built-around-json-api (I don't understand this one! :/)
Please help! This thing is giving me a big headache! And it's the last step I need for the app!
Any help or sample code will be greatly appreciated!!
And most importantly, Merry Christmas, everyone! XD
There is Wordpress plug-in called JSON-API it gives you ability to access every object of Wordpress( post ,page ,category.. etc ) in the form of JSON. you can use any rest client like volley from google, retrofit from Square or build your won to access wordpress data.
install Wordpress plug-in
http://wordpress.org/plugins/json-api/
for sample code you can look Wordpress for android source code on github
https://github.com/wordpress-mobile/WordPress-Android
I ended up with writing my own JSON.

Set up a server and get feed from it in android

This may not be the type of question I am supposed to ask here but I don't have anywhere else to go. I want to make an android application which gets feed from a web-server and displays in the application. It will be kind of a newspaper app. I have done my share of work: I know android application developemnt: have made some apps. Also, I have an idea of UI: a listview with the feeds and then on selecting an element I will open another activity with the complete feed. What I wanted to know is:
How to set-up a server for this?
How to request?
Can I set-up a free server?
I dont want to use GCM as I don't think it allows sending pictures. Plus it allows small data to be sent. Also, I have no knowledge about the 3rd party server I may need to create for this.
I would want to post both text and photos (combined makes a post, total of around 10 posts) from the server. Please dont close as not a question. Any link, tutorial will be highly appreciated. For server side coding, I know php, .net. I have never coded in java for a server, but I can learn it.
Please follow following steps to get your project done.
Set up any php or Java or .Net Server (If you are aware of any of these web technologies)
After you set up server you need to make web service which will work as mediator to transfer data between your server and mobile.
Webservice response will be either in JSON or XML
Generate response according to your need and parse them on android side.
Display in listview :) :)
You can use JBOSS for your server, and do a Java Server with Webservices.
In your webservices you'll have a service that get all the feeds, and maybe another that request the complete feed...
Your "language" between the Android app and the Server, you can use XML with SOAP (ksoap2 for Android), or you can try JSON (I never used, but I will 'cause we goona need use in my service).
You can try find another free server side, but I think the SOAP is important in most of the servers to "talk" with your app.
I hope helped you.
[]s
Bertan

Categories

Resources