I want to ask how could I get user's which is logged into app email as string value? I have only seen tutorials how to get it using json and then send it to web service which I don't need. Maybe someone could show me the simple way of getting user email?
The Graph API always returns JSON. So, no, I don't think that this is possible. The Android SDK provides convenience classes, so I don't really see a big effort using those. You can use JSONObject.get("email") to retrieve to value of the email property I guess.
See
https://developers.facebook.com/docs/android/graph#userdata
http://developer.android.com/reference/org/json/JSONObject.html#get(java.lang.String)
Related
Hello I am beginner to Android development so I want to ask how to create dynamically changeable database (content) in Android?
I'm aware of sqlite shared preferences but how can I interact with them via internet and add new information like news apps? Could Parse help?
This is not a answer, but a comment rather, I don't have the 50 rep required to comment.
It all depends on the sort of functionality you want to achieve. I.e. do you want to be able to push new content to the device using the internet such as push notifications.
OR
Do you want the app to make a http connection to a api or your own news service on startup or on button press for example?
UPDATE
Ok you have decided you want something similar to option 2. I am not going to write code for you but I will point you in the right direction and if you get stuck, post a question.
Please take a look at:-
https://play.google.com/store/apps/details?id=com.rsoftware.news
If you have decided this is what you want or similar, this application uses an API calling infrastructure.
The API they use is called FAROO.
http://www.faroo.com/hp/api/api.html
I suggest reading the documentation, deciding if this is indeed what you want, then sign up and get a API key. Afterall it is free! enjoy coding, enjoy the errors that you will receive and persevere =).
How to make a API call
I suggest when using a API, test the queries through the browser first of all or use something like Runscope for testing their services. So first get their URL which is:-
http://www.faroo.com/api
If we were to go to this url we will get a 401 response code, which means unauthorised. This is because we haven't added our unique API key to the html query. So this url can take parameters. We simply append a ? to the end of the url and supply the parameters that FAROO offers such as:-
q which stands for query (what do you want FAROO to search for?)
start which is the number it should start from
length which is the number of results you want FAROO to return
key which is your unique to make the requests
etc etc...
So an example of a complete url would be:-
http://www.faroo.com/api?q=iphone&start=1&length=10&l=en&src=news&f=json
This url is for demonstration purposes... your own url will have a key=YourAPIKey
Also notice how the parameters are separated by & symbols i.e. q=iphone&start=1 so this part q we know stands for query which is iphone & start=1 & so on.
Hope this helps.
In my app a user can (only) see the values uploaded by admin.
For example. A salesman is using the app will be able to see the latest rate provided by the manger to trade.
Now the question is "where to put these values?"
I have .net webservice experience with android but I guess it wont work in this scenario,will it?
Any suggestion that the returned result be in (preferably) XML format.
It sounds like you already know how to do this. You can download and parse xml within your app. If you alreayd know how to set up the websever, the rest is easy. Limiting who can see what is just a matter of associating specific transactions with an individuals account. Then just have the phone check for updates on that transaction when the app loads (using someting like AsyncTask) or if you want to get more complicated you could push notificatinos using the android cloud service, or even use a REST model. More details are needed for a more specific answer but you can do what you want.
You can do it on your own, and build a webserver with a MySQL/PHP JSON API or you can use parse.com for a smaller project.
I am trying to implement the stream (news feed) paging function to my app, but it does not work as expected. I found many similar questions here but there are no solutions to solve this problem.
I tried both Graph API and FQL and the behavior was similar. It succeeds to get the result one or two times but after that, it fails to get the result (gets the empty JSON array).
Finally, I found this problem depends on access_token. If I just change the source code to use Android SDK Stream Example App ID rather than my own App ID for authentication, it works perfectly.
So, I believe the Facebook server checks the App ID and returns some weird or restricted access_token to my app.
Are there any condition to get the valid access_token? I tried the exact same permissions with Android SDK Stream example app, but it could not solve the problem.
Will changing the App ID (to get the valid access_token) solve the case?
Verify your app has the read_stream permission. Without it you will not get any non-public objects.
There also seems to be some general LIMIT OFFSET issues with FQL and stream. See Facebook FQL stream limit? and http://developers.facebook.com/bugs/303076713093995.
Try using the SDK on Facebook. Then get the access token.
Use the Facebook SDK for Android. It can be found here. There are getter and setter methods to get and set the access token. The first time you do a single sign-on (SSO), you must save the access token in SharedPreferences and there's no need to reauthenticate again and again.
Just set the access token from your preferences and make a call to the feed dialog. The offline_access permission is to be deprecated. The Facebook SDK for Android does the rest of the work. Just supply sufficient parameters through Bundle.
A couple of things on Android:
get right permissions "read_stream"
Use the android SDK
Check the sample that came w/ android. In the onCreate(), I authenticate Facebook object
this.facebook.authorize(this, new DialogListener() {....}
Test using Facebook's Graph API Explorer.
If you paste in some code I can help you debug further.
The access token returned by Facebook server is valid only for a particular period of time. After which you need to refresh your access token, which is a tedious job.
So, in order to avoid this and maintain your token, you need to add the permission "offline_access" to your permission list. This is the approach used by almost Facebook-related apps.
I want to get the recent activities of my facebook friends per day basis. I mean to say can i get my facebook friends wall? Thanks.
yes you can... all you have to do is query the graph api like this :
https://graph.facebook.com/{user_id}/feed
You will have to request the read_stream permission from the user in order to gain access to this data.
Here is some information about permissions.
Here is some information about using the graph api.
EDIT:
Apologies, you can not retrieve information from a friends feed. What you will have to do is request offline access from your users and only then will you be able to retrieve data from that users feed in order to give it to another user.
I never used the Below solution,But I am sure there's Way to do this using FQL
You will have to write a Query to GRAPH API and Using HTTP GET and you will get the data in JSON format,something like this not Completely sure but check the link FQL
https://graph.facebook.com/fql?q=SELECT+activities+FROM+user+WHERE+uid1=Friend'sID&access_token
from the USER table.
Hope you will get the solution,And If you try let my know your experience.
I am trying to read tweets from a dinamically given twitter user in a Android app.
I found here (stackoverflow) and at google some ways to connect to twitter, but i didn't find a simply way to obtain the tweets of a given user without a loggin on twitter. I found some ways to do something similar with java, but using license protected librarys, and also i need to know the specific way with android (not java), without using license protected librarys.
There is a way to do it?
Don't bother using libraries, just grab the data from the web.
JSON: https://api.twitter.com/1/statuses/user_timeline.json?screen_name=barackobama
XML: https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=barackobama
Just replace screen_name with any non-protected user and it'll work.
Use Twitter4j library and the "Search for tweets" example.
You will not need to log in, just put the username whose tweets you want to read in the query and that's it.
Another way, if you dont want to use specific libraries, would be parsing the twitter page, with HtmlParser.