Validate Facebook work position targeting IDs - facebook

Our Facebook Ad system uses work position in its targeting spec as documented here: https://developers.facebook.com/docs/marketing-api/targeting-specs/v2.3#education_and_workplace
Sometimes Facebook deletes existing work positions and API requests to update the targeting spec fails:
{
"error":
{
"message": "Invalid parameter",
"type": "FacebookApiException",
"code": 100,
"error_subcode": 1487079,
"is_transient": false,
"error_user_title": "Invalid Targeting Spec",
"error_user_msg": "The specified targeting spec is not valid because: Job Titles with id 1542119359378854 is invalid."
}
}
The same happens with interest, but there is an API request to validate interests: https://developers.facebook.com/docs/marketing-api/targeting-search/v2.3#interest_validation
Is there something similar for work positions? (Probably undocumented?)
I could do requests to the /search/ API endpoint, but then I'd run into API request limits.

Unfortunately you are out of luck; there is no validation feature for work positions.
However, the example on the Facebook docs page you mentioned ([{'id':105763692790962, 'name':'Business Analyst'}]) seems to contain a working Facebook ID. Fetching e.g. https://graph.facebook.com/v2.2/105763692790962 will return the following output, so long as this profession exists:
{
"category": "Profession",
"name": "Business Analyst",
"id": "105763692790962"
}
This is of course not entirely what you are looking for, but if you want to limit the number of requests you make, you could implement your advertising app in such a way that it only tries to resolve professions by their ID once you run into trouble with your targeting spec. Getting back data for such a sanity check-request indicates that a work position is still valid. Should it not be valid any more, you can resort to using the /search endpoint to find a replacement.
You could also suggest that Facebook add this feature: https://www.facebook.com/help/suggestions

Related

Facebook object not found

Via the Facebook Graph API it is possible to get the cover image of an event via the following GET-Request:
https://graph.facebook.com/169768270447838?fields=cover&access_token=<ACCESS_TOKES>
Good for the following event id it works (UrL: https://www.facebook.com/events/925315510978238/):
925315510978238
But for the other event id it doesnt work anymore (https://www.facebook.com/events/169768270447838/):
169768270447838
{
"error": {
"message": "Unsupported get request. Object with ID '169768270447838' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "CnDEBaBv1HG"
}
}
It worked few days ago, and I dont know why it doesnt work anymore.
Most likely related to this:
Testing of our more robust process starts today and the new process should resume in a few weeks, but apps currently accessing Events and Groups APIs will lose access today.
Source: https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes
This may be interesting for you too: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes

Facebook Graph API Explorer returns OAUTH Exception

In the Graph API Explorer tool I'm using this query:
search?q=myemail#gmail.com&type=user
But for whatever reasons I'm getting this returned.
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}
}
The access token is there. And other requests work, like this one:
me?fields=id,name
Here's the return value
{
"id": "somelongnumber",
"name": "my name"
}
Not sure what I'm doing wrong, are there additional permissions that I have to setup to get search to work?
Edit: Here's the screenshot of my user permissions:
I have also tried using an application token, but same thing.
More updates:
Querying for names seem to work just fine:
search?q=FirstName LastName&type=user
returns valid results, but email returns me oath exception. Did facebook change the way they allow for email searches?
Even though it was possible, you can't search users by their e-mail addresses anymore. As the doc states, the q value must refer to the name of a user.
Available Search Types
Type: user
Description: search for a person (if they allow their name to be searched for)
q value: name
Also the dot character which is/are present in every e-mail address would also break your Graph request. In the current Graph API syntax, . marks the beginning of a subfield, for instance:
/me?fields=friends.limit(10)
^
How would the email be delimited? As you can see,
/search?q=john#gmail&type=user "works"
whereas
/search?q=john#gmail.com&type=user doesn't.
Edit: This feature has been disabled in April 2013 and Facebook reported:
This functionality was deprecated because
of low utilization, and we have no current plans to re-enable it. If
you have a valid use case for this feature please describe it here for
consideration. Marie Hagman — Facebook Team
Source: https://developers.facebook.com/x/bugs/453298034751100/

How do I search Facebook for all users at a certain location using Graph-API

I have a project where I have to search Facebook for all people at a
certain location and then apply further filters to the data. My problem and question is:
How do I get the initial data, using Graph API?
I know that it is possible, using the search field in Facebook itself. Just typing "All people living in ???" returns a list of people.
I couldn't find such functionality in the Graph-API of Facebook. Here is what I tried:
I modified some parameters of the standard search request
search?type=user&center=52.946758,-1.172882&distance=1000
search?type=user&center=Nottingham&distance=1000
and here is what I got:
{
"error": {
"message": "No node specified",
"type": "GraphMethodException",
"code": 100
}
}
Using a similar query with location instead of center
search?type=user&location=Nottingham&distance=1000
search?type=user&location=52.946758,-1.172882&distance=1000
search?type=user&q=&location=Nottingham
and only got a confusing error that the location I wrote is wrong
{
"error": {
"message": "(#160) Invalid coordinates. Coordinates must contain at least latitude and longitude.",
"type": "OAuthException",
"code": 160
}
}
Then searching for a user with the coordinates as query parameter returned an empty result.
search?type=user&q=52.946758,-1.172882&distance=1000
{"data": []}
Then I tried to search for a correct location to pass to the location parameter of the query
search?type=location&q=52.946758,-1.172882
and I only got a deprecation error
{
"error": {
"message": "(#12) location search is deprecated for versions v2.0 and higher",
"type": "OAuthException",
"code": 12
}
}
I don't know how to get to this. If someone could tell me, how to get this information, it would help
me a lot, since I don't know what to try next.
I have found this question similar to my problem, but the accepted answer isn't really answering the question
Facebook Search API - List all users based on location?
You can either search for a location OR search for a user, but you can definitely not search for "all users in an area". The Graph search on Facebook can handle a lot more things that you will never be able to get with the API. Think about privacy, i would not want any app to know if i am nearby, without even authorizing the App ;)
Facebook docs: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search
For getting the locatoin where the user is living, you need to check out the user reference: https://developers.facebook.com/docs/graph-api/reference/v2.2/user
There is a "location" field in there, you need to authorize a user with the "user_location" permission to get that information. It is not possible to get that information from any user. Just because you can see data on Facebook and it is public does not mean you can access it with an App, for privacy reasons this is only possible by authorizing the user.
Scraping without an App is not allowed btw, check out the scraping terms: https://www.facebook.com/apps/site_scraping_tos_terms.php
I tried this -> "firstname lastname location" and it works perfect.
For example -> "Sameeksha kumari australia"
The query looks like this
https://graph.facebook.com/v2.5/search?fields=id,name,picture.type(normal),location&limit=500&q=sameeksha kumari melbourne&type=user&access_token=token

Unusual behavior of facebook grap API ("type": "GraphMethodException", "code": 100)

I am having some unusual errors while fetching some data for some users via graph API.
As for example w all know we can get basic user info via graph.facebook.com/username
And it works. But it is not working for some users. Like the user www.facebook.com/sanzida.tanzum is a valid facebook user. So, we should get her basic info via graph.facebook.com/sanzida.tanzum. But when you will try that, you will get the error
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
And it is not a permission issue because use user herself gets the same error when she try to retrive her own data via graph API. Actually the user sanzida.tanzum is invisible to graph API. For example user sanzida.tanzum is on my friend list. You can check here. my friendlist.(it is public). But when I retrive my friendlist via graph API, my friendlist is shown excluding the user sanzida.tanzum ! But she is in my friendlist!
I have tried to contact facebook for this matter because I did not find any doccument related to this matter. They replied it is usual. (probably they did not read my mail at all. I am including the email conversation with facebook)
Hi তৌফিক,
They are getting errors because they are not you... they dont have
permissions to see the same things you do. They might also be missing
an access token. Either way: no bug here.
Thanks,
Emrakul Security Facebook
-----Original Message----- From: *****#ovi.com To: Subject: Report a Security Vulnerability - Unusual bug in facebook graph API
Your Email Address: *****#ovi.com Do you have technical details of
a security vulnerability?: Yes Vulnerability Type: Privacy /
Authentication Vulnerability Scope: Platform Developer API Title:
Unusual bug in facebook graph API Product / URL:
https://graph.facebook.com/sanzida.tanzum Description and Impact: I
was doing some graph API calls for testing purpose. Mostly I was doing
mostly user profile calls. (https://graph.facebook.com/exampleuser)
Somehow I realized facebook is giving following errors for some users
even they are on my friendlist. Same thing occurs when they try by
themselves.
As for eample the user "https://www.facebook.com/sanzida.tanzum" is on
my friendlist. (My friendlist is public.You can check if you want.)
So, according to facebook graph API, I can request the user's basic
info using (https://graph.facebook.com/sanzida.tanzum) But it returns
this error:
"{ "error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100 } }"
Actually graph API can't access nothing of this user. Another
example.. When I request my friendlist via graph API , All friends of
my friendlist is shown except the user (sanzida.tanzum). But she is in
my friendlist! check here (my friendlist is public)
"https://www.facebook.com/toufiqueimam/friends". So why is this
happening only for few users?
Just now I got confirmation that the user herself gets the same error
if she tries to access (https://graph.facebook.com/sanzida.tanzum)
{ "error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100 } }
Reproduction Instructions / Proof of Concept: Reproduction: first go
to https://www.facebook.com/sanzida.tanzum You will see it is a valid
profile. Now try https://graph.facebook.com/sanzida.tanzum You will
get following error
{ "error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100 } }
This isn't a bug, the error means that the data you're trying to access is not accessible to you, does not exist, has been deleted, is not available because you haven't provided an access token from a user who can see it, etc.
See this answer for an example of this error message in relation to Facebook pages: https://stackoverflow.com/a/6847088/21062 - the same is true when trying to access user profiles if that user has blocked you, blocked your app, disabled their account or disabled all apps from accessing their information.
Just an FYI, I ran into this problem, and it wasn't because the user had blocked all applications. In my scenario, my application was attempting to force-convert Facebook's 64 bit integers into a 53 bit JavaScript integer (Node application). It was mangling the value, so when I was making the Facebook GET Request later on in my application lifecycle, I was doing so with the mangled value, and Facebook was trying to tell me "Um, this UserId doesn't exist".
So in my application, I had to use the Node Big-integer add-on, along with the Mongoose mongoose-long plugin for my Mongodb.
Long story short, if you are converting the UserId to it's native 64 bit integer, don't do so unless the intger type in your application is at least 64 bits.

iphone Google Calendar Events

I've been trying to figure this out for a few days now and have read a bunch on the google apis.
In short, I'm trying to build an Iphone app that basically shows my google public calendar but most importantly get the events and do some stuff with them. <-- possibly a different question later.
I am missing something simple. I have created an api key and associated that with my iOS bundle ID. I have not, however, created the OAUTH stuff on the premise :'Use API keys to identify your project when you do not need to access user data'
I dont need the users data, just MY events data. am i correct in this?
I have gotten the gData lib to work and download the events however, i have to enter my email and password in code which is not acceptable. I have seen code where developers are putting their usernames and password in client code. Is that right?
With the my API key i do this #"https://www.googleapis.com/calendar/v3/users/me/calendarList?maxResults=10&key=xxxxxxxx";
and get this:
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Do i HAVE to use oauth? Where should i go from here?
Thanks!
I think I have found that i must use an oAuth token. this page has been most useful to me
http://cornempire.net/2012/01/15/part-3-oauth2-and-configuring-your-application-with-google/
And i believe is the best way of handling authentication if i HAVE to use oAuth. Though I'm not sure why if i tie my API key to my iOS bundle ID.