How to obtain a fbid list from fbapi2.0 without accessToken - facebook

i need to map the same person's fbID between the old app(fb1.0) and new app(fb2.0)
Can i get the fbid list via a http request without accessToken??
That means i want to pull the fbid list with both my appkey & a user's fbid.

In order to match User IDs between different Apps, you need to use the Business Mapping API: https://developers.facebook.com/docs/apps/for-business
Consider reading the v2.2 changes of the changelog too:
A new token_for_business field makes it easier to identify the same person across multiple apps owned by the same business
Source: https://developers.facebook.com/docs/apps/changelog
For getting details (or just the ID) of a User, you always need an Access Token.

Related

REST API Resource Naming Conventions - User or Users (pluralisation)

Long Version
For some, myself included, one of the most painful and headache causing parts of building a REST API is determining the name for each resource and the accompanying endpoints.
Whilst it is, of course, down to personal preference; there are certain things that are encouraged by the community. For example, most people, including me, will pluralise their resource names:
GET /notifications
POST /posts
However, there are cases where pluralising just doesn't seem correct. Consider the following example where user essentially represents the logged in user, not the entire users resource:
Endpoints only relevant to the authenticated user
// Phone Verification
POST /user/phone/request
POST /user/phone/resend
POST /user/phone/verify
// User creation based on authenticated and verified phone
POST /user
// Update authenticated user's profile
PUT /user
// Delete the authenticated user
DELETE /user
// Add/remove the authenticated user's profile image
POST /user/image
DELETE /user/image
// Update the authenticated user's device token
PUT /device/token
Endpoints that access the entire users resource
GET /user
GET /user/{id|self}
In the above example, to me, it feels like the singular user resource name is more suited given on the majority of the endpoints, user refers to the authenticated user, not the entire database of users. But, on the other hand, having GET /user return all users just seems plain wrong...
As a result, I am now torn between user and users - both have strong arguments either way as I see it but would very much welcome another person's opinion on the matter...
Short Version
TLDR - To put it simply, consider the following two endpoints:
// Get all users
GET /users
// Update the authenticated user's device token
PUT /user/device
Both of the above seem correct in my eyes. The problem with the above is that there is no way I am going to have both user and users, it has to be one or the other in my opinion.
The dilemma; Why would I use user when the resource refers to the entire users database? Why would I use users when the resource only refers to the authenticated user?
I cannot get my head around this one... Anyone got any thoughts on this? Or, even better, an alternative solution to my proposed endpoint structure?
Update
After some deep thinking, I have come up with an alternative solution to this but I am still not 100% sure on it as I am not overly keen on using the auth resource name.
Consider this:
// auth = authenticated user
// users = users collection
POST /auth/request
POST /auth/resend
POST /auth/verify
POST /auth
PUT /auth
DELETE /auth
POST /auth/image
DELETE /auth/image
PUT /auth/device/token
GET /users
GET /users/{id}
There are obviously different opinions on this matter, the answer below contains my personal views.
The bottom line is that it's all quite subjective and depends on the way one looks at a certain (type of) resource.
Why would I use user when the resource refers to the entire users
database?
In my opinion, you should never use singular for an endpoint that contains multiple resources.
Some people, however, argue that we should stick to singulars for all resources, mostly for the sake of simplicity and uniformity.
Why would I use users when the resource only refers to the
authenticated user?
You will find quite some different opinions on this, but the consensus and most widely adopted is generally to stick with plurals, except for resources that can only contain a single item (for example, a user profile only containing only one avatar).
Also, since using a singular form for the users resource wouldn't make sense following the above logic, we don't want to mix singular and plural names.
// Update the authenticated user's device token
PUT /user/device
You can interpret 'updating the authenticated user's device token' as follows:
Add a device token to a user entity of the users resource collection.
If your API supports view devices' data of other users, the API can be like /users/$user_id/devices
whereas, when you always have to get the current logged-in user's devices information, the API can simply be /devices (as current user is implied).
i.e IMO, wherever you have only 1 parent resource accessible (say in this case current user is always singular), you can skip that resource in the API URL.

How to get Authenticated user's Google Ad Account ID using Google Ads API v0 using a REST API?

I have been trying to figure out after referring to their official documentation (Google Ads API Document) which is not clear enough
Here is what I have tried till now.
I have created an app where users can log in with their Google Ad words account. I need to fetch their Ad performance reports via REST API.
To make an API request to fetch performance reports, we need the Google Ad Words Account ID of the authenticated user. Currently, as I am testing it with my personal account, I can login to my Ad words Console and get the Ad Words Account ID. But, how do I fetch the Ad Words Account ID dynamically for other users who authenticate via my App?
I tried looking for a way in their official documentation. But I couldn't figure out.
Could someone help me with the REST API URL which needs to be called to fetch the authenticated user's Ad words Account ID.
In addition to previous answer, I guess this is what you are looking for:
https://developers.google.com/adwords/api/docs/guides/first-api-call#create_test_accounts
It explains how to setup Google Ad Words API and get your ID.
According to the documentation here Account overview, you need to list the customers to get the ID. For each user that logs in as long as they do not have access to multiple accounts you should get a single customer and their ID.
CustomerService
CustomerService provides information about your accounts. It has a
getCustomers() method that takes no arguments and returns a list of
Customer objects containing fields such as customerId, currencyCode,
and dateTimeZone. CustomerService also has a mutate() method that can
be used to update various attributes of a customer, including the
autoTaggingEnabled and conversionTrackingSetting fields.
If no clientCustomerId is specified in a request, the response will
contain multiple entries if more than one account is directly
accessible by the authenticated account.

Endpoint to get the currently authenticated Rally user?

I generated an API key for my Rally account. Is there a REST API to retrieve my basic user information, such as name, ObjectID, and ObjectUUID?
Sure, you can just read the /user endpoint and fetch whatever fields you need. This endpoint can both be used to query for multiple users, or if just read without any parameters it will return yourself.
So, to get yourself:
GET https://rally1.rallydev.com/slm/webservice/v2.0/user?fetch=ObjectID
Or to query for users (which you're probably familiar with):
GET https://rally1.rallydev.com/slm/webservice/v2.0/user?fetch=ObjectID&query=(UserName contains "Bob")

Google + Domains API domain wide delegation

I am trying to write a powershell script that uses the Invoke-RestMethod to connect to the Google + Api and authenticates with a service account that has been granted domain wide delegation of authority. Then I want to use a list names to retrieve the google + userid and from there I want to create a circle and insert all of those users into that circle.
The main issue I am having is retrieving the userid for the list of users, I think I would be able to figure the rest out once I had that piece.
Thanks
The Google+ Domains API is unique in that it allows you to make API calls using email addresses in the place of the Google+ ID. This means that if you have a list of users within your domain, you may make API calls on their behalf, by specifying their email address when building the authorized API client.
In Java, this is done by calling setServiceAcountUser on your GoogleCredential:
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
.setServiceAccountScopes(SCOPE)
.setServiceAccountUser(USER_EMAIL)
.setServiceAccountPrivateKeyFromP12File(
new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
.build();
For additional examples and information, check out https://developers.google.com/+/domains/authentication/delegation.
Also, if you do wish to compile a list of Google+ IDs, you need only make a people.get API call using the email address for the authenticated user, and the Google+ ID will be included in the Person response. (https://developers.google.com/+/domains/api/people/get)

Oauth - Facebook/ Twitter / Foursquare

I am creating a way people can connect their Fb, Twitter and FS account to the account they create on my application. I wanna create a single table where i can store all the required stuff..
User(id, username, password, email)
Oauth (id, user_id, oauth_provider, ....... )
As for my Understanding
Facebook needs facebook id
Twitter needs id, token, secret
Foursquare requires email and consumer id.
Just wanted to confirm i am doing it right.. in constructing the Oauth Table.
I personally create a field named "setting_parameter" for the requirement's value because all of these API need different things. As you've said Facebook need App ID (plus Token), Twitter needs Consumer Key and consumer Secret..
All of this value I merge them all into one string with JSON-format. I don't put them each into the field because I think there won't be necessary for me to query this table for operations other than get their value. Beside, I need to implemented other APIs in the future. That's why I can't create special field, because I won't know what kind of value the new API will going to need next time. That's why I prefer to squished them into one string field.
The table of mine is like this
Oauth(id, name, setting_parameter, description,...)