facebook graph api 601 exception. getting exception in the graph api - android

I'm new to graph API... I'm running the FQL query in the graph API
SELECT name, FROM user WHERE uid = me()
I'm getting this error...
please help me.. thanks in advance
{
"error": {
"message": "(#601) Parser error: unexpected 'monthly_active_users' at position 0.",
"type": "OAuthException",
"code": 601
}
}

SELECT name FROM user WHERE uid = me()
remove the coma after name
if you want to add more selection add coma
like this
SELECT name,id FROM user WHERE uid = me()
this video link might help you better understandign in fql
link

Related

How to handle dynamic error response in android using retrofit?

I am currently working on new android project with feathersjs back-end. Before error response normal format like,
{
"code": 123,
"message": "An error occurred!"
}
But now structure change dynamically according to the api request body. For Example I have three input field in my UI like Name, age, email after hitting api if wrong data error response will be like,
{
"code":123,
"error":{
"name":"Name is wrong",
"age":"Age is greater than 18 is mandatory",
"email:"Invalid email id"
}
}
So I need to link Error response to correct Edittext Field and set Error Message. How I link this ?. But Request Body field name and error response field name are same.
Request Body structure :
{
"data":{
"name":"xxx",
"age":"24",
"email:"xx#gmail.com"
}
}
Detail Explanation with Example Code will be more helpful.

How to get all the posts of a facebook page?

I want to get all the posts of a facebook page. I am following the link https://developers.facebook.com/docs/graph-api/reference/v2.8/post
For example URL : http://graph.facebook.com/v2.8/{page_id}/feed%20HTTP/1.1
I get the response as :
{"error":
{
"message": "Unknown path components: /feed HTTP/1.1",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "Em5dm7wPr9k"
}
}
I got the page_id from my facebook page.
Is my URL correct? Is this the correct way to get all the posts?
This is the correct way: https://developers.facebook.com/tools/explorer/?method=GET&path=bladauhu%2Ffeed&version=v2.8
You don´t need the Page ID, but you need to get rid of the " HTTP/1.1" in the API call. It´s just http://graph.facebook.com/v2.8/{page_id}/feed.

Facebook Graph API - Android - URL comment count is wrong

I have read this "Facebook comment-count always showing 0" but it isn't my case.
I use graph API for android to count number of comments on a url link. Just look a simple example:
1 - Use graph explorer: Press this. You will see the result is "comment_count": 47 at this time, and a line "id": "https://developers.facebook.com/docs/plugins/comments/" that content the link we count.
2 - But when I use android facebook graph to query the link like this:
String linkt = "https://developers.facebook.com/docs/plugins/comments/";
String graphLink = "/v2.2/?format=json&fields=share{comment_count}&id=" + linkt;
I got the result {"id":"https:\/\/developers.facebook.com\/docs\/plugins\/comments\/?format=json","share":{"comment_count":0}}
Do you see the "?format=json" was automatically added to my url. So the result is always 0. Because it a wrong url.
Thank you for all help.
I added "&" after my link to separate with "?format=j", then it worked.

Get userInfo from Instagram in android

I am integrating Instagram in my android app. I am able to get authetication and token from Instagram API. Now what I am looking for is userinfo. As soon as user is authenticated I want his userinfo like username,name etc. Any idea how to get it ? I tried several ways but didnt able to achieve it.
I tried this example https://github.com/poller/instagram-demo-for-android
Get basic information about a user. To get information about the owner of the access token, you can use self instead of the user-id.
Link for Documentation is :
https://instagram.com/developer/endpoints/users/
Use this API :
https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN
Response contains information about that particular user requested by passing ID :
{
"data": {
"id": "1574083",
"username": "snoopdogg",
"full_name": "Snoop Dogg",
"profile_picture": "url of picture",
"bio": "This is my bio",
"website": "website of that user",
"counts": {
"media": 1320,
"follows": 420,
"followed_by": 3410
}
}
Simply pass your access token to this url. And you will get the logged user information of the Instagram.
[https://api.instagram.com/v1/users/self/?access_token=YOUR-ACCESS-TOKEN]
this will return the user information like the above #Heena Arora mentioned.
And also she mentioned about retrieving the user information for the particular user by id.

FQL query error: "An unknown error has occurred."

I've started facing some problems with Facebook FQL without any change to my code. And they're also getting solved without any change!
I'm receiving this annoying message that has no clear indication of the problem and possible solutions.
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
I've been using FB-SDK for Android and changed it to parse content from url (GET) and the problem still existing.
I'm trying to trigger this simple query (that works in the Graph API Explorer).
SELECT name,price_range,type,location,page_id FROM page WHERE page_id in (SELECT page_id,latitude,longitude FROM place WHERE distance(latitude, longitude, '-30.03852', '-51.17877') < 50000 LIMIT 20) AND (type='RESTAURANT/CAFE' OR type='LOCAL BUSINESS')
The url used is the following
https://graph.facebook.com/fql?q=SELECT name,price_range,type,location,page_id FROM page WHERE page_id in (SELECT page_id,latitude,longitude FROM place WHERE distance(latitude, longitude, '-30.03852', '-51.17877') < 50000 LIMIT 20) AND (type='RESTAURANT/CAFE' OR type='LOCAL BUSINESS')&access_token=ACCESS_TOKEN
Any help??
Your query works fine. I suggest to Log your active session token and make sure it is open when running query. You can check then state of session by using isOpened method
activeSession.getState().isOpened()
best of luck :)

Categories

Resources