Facebook Insights API not returning store visits data - facebook

I am trying to retrieve Store Visits data from the Facebook Insights API. Based on their documentation, these should be available by specifying the following parameters:
store_visit_actions
cost_per_store_visit_actions
When I use store_visit_actions as a parameter, no data is returned. I know data exists because it is displayed through their UI reporting tool.
When I use cost_per_store_visit_actions, I receive a 100 invalid param error:
cost_per_store_visit_actions is not valid for fields param.
These params are listed as "In Development", however, I'm retrieving other development parameters without issue. Is anyone facing the same issue or know how to fix?

this is because the metrics
store_visit_actions
cost_per_store_visit_actions
are deprecated in facebook api v11.0. You can checkout this link:
https://developers.facebook.com/docs/graph-api/changelog/version11.0/

Related

Facebook Insights API Conversions are NOT matching Facebook Ads manager Results

When trying to fetch Facebook insights API for the following action offsite_conversion.fb_pixel_purchase I always get less number than Facebook show on their ad manager, I tried to inspect their network calls and URL structure and I see they're using the same field offsite_conversion.fb_pixel_purchase to show Results I am not sure why the numbers are mis-matching. I tried to query from the Graph API and from my shell with the same results.
You may check use_account_attribution_setting and use_unified_attribution_setting in here: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group/insights
Setting use_unified_attribution_setting to true worked for me.
I did some testing and found out that if you use an additional breakdown, FB will return less conversions. There might be a bug in their API when you use breakdowns.
I tried getting offsite_conversion.fb_pixel_purchase with
'breakdowns' => 'hourly_stats_aggregated_by_advertiser_time_zone',
and facebook retuned 5 conversions.
if I remove the breakdown and get the data grouped daily I get 11 conversions which is what Facebook Ads Manager shows

Provide array of URNs to LinkedIn REST API?

I am using the LinkedIn Marketing Development Platform where I am trying to provide a list of company URNs to to the Ad Analytics API. However, when I try to provide a list of company URNs, it fails with status 400.
Analytics Finder endpoint docs
My request:
GET https://api.linkedin.com/v2/adAnalyticsV2?q=analytics&pivot=CAMPAIGN&dateRange.start.day=1&dateRange.start.month=1&dateRange.start.year=2017&timeGranularity=ALL&companies=urn:li:organization:1234,urn:li:organization:5678
Response:
{"message":"Array parameter 'companies' value 'urn:li:organization:1234,urn:li:organization:5678' is invalid. Reason: Deserializing output 'urn:li:organization:1234,urn:li:organization:5678' failed","status":400}
I have also tried URL encoding the URL, and providing the list via the parameter companies[0] as is done in other examples in the docs.
What is the correct way to input arrays to the LinkedIn API?
Edit: Changed accounts to companies
So the Protocol Version actually gave me some useful insight. There are a couple of ways of providing arrays in parameters.
From the docs:
For Restli V1.0 (used by default)
GET GET https://api.linkedin.com/people?ids=1&ids=2&ids=3
For Restli V2.0, which you can use by setting the following header: X-RestLi-Protocol-Version: 2.0.0
Pass parameters in List format.
GET https://api.linkedin.com/v2/people?ids=List(1,2,3,4)
However, I have not managed to get the Analytics Finder API to work with Restli V2.0.
You'll need to provide the list of URL encoded organization URNs to the accounts param. Using your request as an example:
&accounts=List(urn%3Ali%3Aorganization%3A1234,urn%3Ali%3Aorganization%3A5678)

facebook4j post from is null

I am using the Facebook API from Java with Facebook4j.
I have two servers, on the one that uses Facebook 2.3 API when I get the from of a post,
Post post = connection.getFeed().get(0);
post.getFrom();
I get the user, but in the server that uses Facebook 2.4 API, the from is null.
Any idea? I don't see any documented change in the fb API.
As described in the Facebook Platform Changelog, as of v2.4, you now have to manually specify fields if you want them to be retrieved:
To try to improve performance on mobile networks, Nodes and Edges in
v2.4 requires that you explicitly request the field(s) you need for
your GET requests. For example, GET /v2.4/me/feed no longer includes
likes and comments by default, but GET
/v2.4/me/feed?fields=comments,likes will return the data. For more
details see the docs on how to request specific fields.
According to the docs on Post, the relevant field is named from. To request this field in the me feed using Facebook4J, you can use a Reading object, as follows:
facebook.getFeed(new Reading().fields("from"))

Facebook Graph API version change - can't retrieve posts

Since Facebook's Graph API changed to version 2.4, I find that any query attempting to retrieve posts made returns an error:
type: OAuthException, code: 1, message: An unknown error has occurred. [HTTP 500]
My request code uses Facebook's koala ruby api to make requests:
posts = #graph.get_object(appid+"/posts?limit=20",api_version: "v2.3")
I added the version count now, based on koala's recommendation, but the result for this is still the same error that I got without specifying the version. My access token is definitely valid, does anyone know if something else has changed or if this is a bug?
Extending #Tobi 's comment. You have to pass a page/event/user/group id to retrieve the post.
Also, you've to explicitly pass fields parameter to query additional data of a post. So your query will become:
posts = #graph.get_object(id+"/posts?fields=id,name,message,picture&limit=20",api_version: "v2.4")
Please refer to this document of Facebook Developers to learn more about /postsedge.

Facebook graph api - Unsupported get request

I'm creating a custom module in Drupal, that for part of its functionality must fetch posts from a business page. So for simplicity, I'm using fbapp module as a dependency (drupal.org/project/fbapp), so that I can use it's authentication and request functions (fbapp_app_authenticate() and fbapp_graph_request()) without having to worry about the constant facebook graph updates making my own code obsolete.
I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access_token. However, when I try to read posts from a publicly available page (the clients), I get the response:
"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"
Here's the queries and responses my code produces:
graph.facebook.com/oauth/access_token?client_id=<redacted>&client_secret=<redacted>&grant_type=client_credentials
array(1) {
["access_token"]=>
string(43) "<redacted>|<redacted>"
}
graph.facebook.com/<page_id>/posts?access_token=<redacted>|<redacted>"
string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"
Can anyone verify a correct way to query a Facebook page programmatically, perhaps there's a setting in the page I'm querying that I need to set (although I can't find anything)?
If page restrictions apply, the page's feed can only be retrieved with an user access token as far as I know (because FB needs to evaluate the visibility criteria, and setting your app to the same restrictions doesn't help here):
See
https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed#readperms
It looks like everything you have done is correct. The response you got can be (i am not sure) because you got your clients pageid wrong.