Preferred Currency API returning only ID - facebook-graph-api

I'm currently trying to implement the preferred currency API, but all the graph API is returning to me is the user ID.
I go to the following link:
https://graph.facebook.com/100001342672661?fields=currency&access_token=XXXX
I get this back:
{
"id": "100001342672661"
}
I've looked in the graph API explorer and get the same result. There are no errors, and "currency" appears to be a valid field, it's just not returning anything. Any ideas as to why this is happening?

The FacebookId and the user access_token are not matching, this is why you're getting only the FacebookId as an answer.
Allow the app on your developer account
Get a user token for your app: https://developers.facebook.com/tools/access_token/
Go to https://graph.facebook.com/me?fields=currency&access_token=XXX (XXX being the user token you just retrieved)

Currency is indeed a valid field. Are you sure it is set? For me it seems it isn't (and that's why it only returns you the id) but I'll look to find out it if there's any bug related to it.

Related

Documentation Bug? FB Graph API explorer cannot return /me/address

I am playing FB graph API explorer which is a fantastic tool to test graph API. But I met a weird case.
First of all, I have a access token with all permissions to access myself account.
Here is my query:
me?fields=id,name,address
But I only got:
{
"id": "alongnumber",
"name": "stringname"
}
Where is "address" returned?
Thanks
Derek
#Tobi suggests it might be a documentation bug. Can anyone confirm it?
There is no such field as address. Have a look at
https://developers.facebook.com/docs/graph-api/reference/user
to see which fields are currently available. To get the current location, you can use me?fields=id,location{id}, and then request the location.id object in a second request to get the location details.
There is no field like Address though there is current_address & current_location but they also don't seem to work with basic permissions.
Check this for all the field names which you can get from the API. https://developers.facebook.com/docs/reference/fql/user#columns

Asana API Query Error "Empty Field Name"

I am starting to write the Asana API using Embarcadero EX6 that is using the built in REST Client. I have my RESTClient, SimpleAuthenticator, RESTRequest and RESTResponse controls in place so there isn't any code to show since it’s all done within those controls. I am not getting a “Not Authorized” return error so I think the API key and authorization is setup correctly. However I am getting the following response back when I run a query for users. The RESTRequest is using POST.
{"errors":[{"message":"Empty field name"}]}
Any ideas?
POST is (generally) for creating, so you need to specify the fields of the resource you want to create. In this case to retrieve users you want to use a GET.

Unable to access user's username using Facebook api 2.0

I am using facebook api 2.0 to allow users to use their Facebook profile data to fill up my custom form. (I don't want facebook's prefilled form). I am getting other information like first name, last name, email. But apparently Facebook api 2.0 has removed username from response object and I am unable to access it. I have observed that Response.link contains url of the person's profile and the portion after "www.facebook.com/" is identical to username. If we succeed in fetching link, we could get Username. But I am not sure this is true for all users. However when i try to access the link, I get link with app scoped id like this:
"www.facebook.com/app_scoped_user_id/XXXXXX/"
where last portion (XXXXXX) is some numerical id. Does anybody know how to access the link in the form of "https://www.facebook.com/username"?
Also, if we are not able to do that in 2.0 but we can in 1.0, then how to switch back to 1.0?
As https://developers.facebook.com/docs/apps/changelog#v2_0_api_versions is clearly stating
/me/username is no longer available
If your app is created after April 30th 2014, there's no way switching back to v1.0. If not, you can prepend /v1.0 to your request, but that will only work until April 30th, 2015.
If you only require current authorized user's username(or any other authorized user for your app), then it's possible.
First step, you call /v2.0/me?fields=third_party_id endpoint . You have to use authorized User Access Token (Authorized with basic scope, i.e. public_profile permission enough).
Or alternative way, you can use App Access Token instead. Of course you can't use me connection anymore, you have to explicitly to put User ID. For example, 12345678 shown on the folowing screenshot:
Second step, use App Access Token (User Access Token is not allow here) to call following FQL query:
SELECT username FROM standard_user_info WHERE third_party_id =
'example12345abcdef'
In which "example12345abcdef" is the third_party_id example you get from the first step.
p/s: please note that the user/app access token on first step must use the same app on second step. It's because third_party_id is tied to app.
Cheers :)
Note that username is optional on Facebook. By default a Facebook profile doesn't have a username
In any Facebook API response, you'll get the username, only if the user has set his username under his Facebook settings.
If you just need to show the user his name why not use the "name" field? It contains their first and last name both. I have changed my app to use name instead of "username".

How to get user's username in v2.0 or later of Facebook's Graph API

I used to get the user's username in the API 1.0 fairly easily, using /me and getting the username property of the response object.
Now I'm getting this error with API 2.0:
"(#12) username is deprecated for versions v2.0 and higher"
The only way I found to get this until now was to use FQL, but now it seems deprecated.
Is there a way around this?
I don't mean to be unhelpful, but it appears access to username has been removed from the API, as far as I can tell. Places where an app may have been using username, such as in the old share dialogs, can no longer do that when used with the 2.0 API. I think its also a way of preventing apps from having access to usable unique identifiers outside of the app scope - any user IDs you retrieve under 2.0 API are specific to your app alone.
I found a simple workaround that involves a get request to Facebook. Instead of the username, Facebook will give you an ID that is unique to your application.
I have found that making a request to https://www.facebook.com/[profile_id] will then redirect to the user's real profile. The username can be extracted from the redirect URL.
Example:
> curl -i https://www.facebook.com/710290539
HTTP/1.1 301 Moved Permanently
Location: https://www.facebook.com/colinskow
(Note: Since I am the owner of the app in test mode, this could possibly be an exception. Please let me know in comments if you are able to confirm this in a production environment.)
As a workaround you can use the email as a unique identifier. Email address can be retrieved using "email" as the permission scope.
Facebook has removed the username field from the new API version. It is not possible to retrieve the username. But Facebook provides an application specific unique ID. If you need to share the same user between several apps you can use the newly introduced Business Mapping API. This allows to add all the required apps to a group. In this case the ID will be unique among all the apps in the group.
More information on Business Mapping API is available at https://developers.facebook.com/docs/apps/for-business 1

Business Facebook page id?

I'm tring to find the Facebook ID for my business page to use with Open Graph. I have claimed my url so I can't see the id
when I enter:
graph.facebook.com/StagecoachWineTours
I get the response:
false
Is there another way?
Your ID appears to be: 97122673369
I got it by visiting the following link:
http://developers.facebook.com/tools/explorer/?method=GET&path=StagecoachWineTours
If it is still showing up as 'false' when you reach it you'll need to click on Get Access Token. After that a dialog will appear, click on Get Access Token once more. Once you have done this click on submit.
The reason you could not retrieve your info appears to be because you need to provide an access token on your Graph API call to fetch it. Once you do that you'll be able to get all sorts of info!