Errors with: https://graph.facebook.com/app_id/insights/share_views/day?access_token= - facebook

I am trying to get the number of users who have seen pages shared from my site using: https://graph.facebook.com/app_id/insights/share_views/day?access_token=
I am filling in my app_id and access_token and I am getting an error response of:
Array ( [error] => Array ( [type] => OAuthException [message] => (#604) Invalid metric name: share_views ) )
Has anyone run into this error and determined the cause?

I believe you need to actually specify time period you are trying to access. For an example of an application that is working and can access Insight data, check here https://github.com/facebook/insights-api-sample.
Notice that they specify a since and until post parameter in this file:
https://github.com/facebook/insights-api-sample/blob/master/php/results.php

Related

Google Analytics Error code 403 Insufficient Permission Perl

before posting I make sure to check other similar threads.
but none has the same problem as mine.
the closest two would be:
Google Analytics PHP API "(403) Insufficient Permission"
and Google Analytics API - inconsistent error "insufficientPermissions' (403)
but there is no specific answer/solution to that thread.
and found this Python Google Analytics Management API throws error 403 Forbidden but I dont really know/understand if this is related to my issue..perhaps someone can enlighten me?
I have 2 clients, A & B. Both claimed has granted me the access to Read & Analyse
I succeed extracting data from A, but failed on B.
I believe, I have both GA Profile ID correct and no coding error (since A succeed).
To confirm that I dont use wrong GA profile ID, GA Profile ID would be 9876543 from the example below
/a12345w654321p9876543/
The error code is 403, insufficient permission for this profile.
GA error: 403 Forbidden {"error":{"errors":[{"domain":"global","reason":"insufficientPermissions","message":"User does not have sufficient permissions for this profile."}],"code":403,"message":"User does not have sufficient permissions for this profile."}} at ./ga_pp_yest.pl line 90.
Then, I tried to give access to the same account on my own website (for testing purpose).
I go to Property level and give permission Read & Analyse. (even tried changing to Account Level with Edit permission)
I still get the same error.
some of my code:
my $analytics = Net::Google::Analytics->new;
# Authenticate
my $oauth = Net::Google::Analytics::OAuth2->new(
client_id => $client_id,
client_secret => $client_secret,
);
my $token = $oauth->refresh_access_token($refresh_token);
$analytics->token($token);
$req = $analytics->new_request(
start_date => "$startDate",
end_date => "$startDate",
ids => "ga:$profile_id",
dimensions => "ga:pagePath,ga:date,ga:hour,ga:channelGrouping,ga:deviceCategory,ga:region,ga:city",
metrics => "ga:entrances",
max_results => "1000",
);
$res = $analytics->retrieve($req);
die( "GA error: " . $res->error_message ) if !$res->is_success;
I checked the token, it gave me 1 hour of access. using this link https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=accessToken
any help is greatly appreciated.
thank you very much

Getting post lists from facebook pages

I'm trying fetch list of post from given set of facebook pages using restfb(java)
List fbPages = Arrays.asList("178697151159/posts", "538560813021153/posts");
JsonObject fetchObjectsSubResults = client.fetchObjects(fbPages, JsonObject.class, Parameter.with("fields","shares,created_time"),Parameter.with("limit", 5));
But I'm getting a runtime error from facebook api as following.. IS there any body that can help me out to resolve this or is this impossible (
Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: (#803) Some of the aliases you requested do not exist: 178697151159/posts?,538560813021153/posts? (code 803, subcode null)
at com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:1278)
at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:1195)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1136)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:1058)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:1020)
at com.restfb.DefaultFacebookClient.fetchObjects(DefaultFacebookClient.java:476)
at main.main(main.java:75)
I suggest using 1 call per page. SO it should look like:
Connection<Post> postConnection = client.fetchConnection(pageId+ "/posts", Post.class, Parameter.with("fields","shares,created_time"), Parameter.with("limit","5"));
Depending on your use case, you can run over the postConnection with a for loop to get all posts or take the data from the first page of the result set with postConnection.getData().
In both cases you can eventually work with a Post type and access the fields your are interested in. The other fields are left null.
BTW working with multiple ids in a single call or request these ids one after another makes no difference to the Facebook calls. The amount that is internally calculated is the same; in your case 2.

Facebook ads api - get stats by day

I can successfully get campaign stats between particular dates via the API however I need that broken down day by date rather than a total.
I can see it works for the page insights API but there doesn't seem to be documentation on the ad insights API.
I'm using the following call to get the total between dates.
https://graph.facebook.com/v2.2/act_/stats?access_token=&start_time=&end_time=
However I cannot find the documentation to break it down into day by day for one query.
This answer had a solution but didn't work.
Downloading Facebook ads statistics in background (no web browser)
Thanks!
===================================================
New info:
So I can use time_increment=1 to get a break down by day however this only works with 'date_preset' however I want to set a date range. I am using the latest API
https://graph.facebook.com/v2.2/act_{$this->accountID}/reportstats
Using 'time_ranges' will merge the data regardless of using time_increment=1
Using 'date_preset' eg last_28_days does work with time_increment.
Using 'time_interval' with midnight timestamps of my timezone (as the documentation suggested) throws the following error:
[error] => stdClass Object
(
[message] => (#100) The "time_start" and "time_stop" must be integer.
[type] => OAuthException
[code] => 100
)
They are integers! Here's my complete post data
$postData = array(
'async'=>'true',
'data_columns'=>$data_columns,
/*
'time_ranges'=>array(
array(
'day_start'=>array(
'day'=>$startDate->format("d"),
'month'=>$startDate->format("m"),
'year'=>$startDate->format("Y"),
),
'day_stop'=>array(
'day'=>$endDate->format("d"),
'month'=>$endDate->format("m"),
'year'=>$endDate->format("Y"),
),
),
),
*/
'actions_group_by'=>array('action_type'),
'time_interval'=>array(
'time_start'=>$startDate->getTimestamp() ,
'time_stop'=>$endDate->getTimestamp(),
),
//'date_preset' => 'last_28_days',
'time_increment'=>'1',
'filters'=>$filters,
'access_token'=>$this->access_token
);
Ok I had to change the format time_interval to the time_range format and it worked! The documentation says timestamps will work but it doesn't, this worked:
'time_interval'=>array(
'day_start'=>array(
'day'=>$startDate->format("d"),
'month'=>$startDate->format("m"),
'year'=>$startDate->format("Y"),
),
'day_stop'=>array(
'day'=>$endDate->format("d"),
'month'=>$endDate->format("m"),
'year'=>$endDate->format("Y"),
),
),

Paypal Adeptive Response Message

can anyone please explain me this error message?
i am using paypal adeptive payments but all is properly setup but this error is coming in light box pop up so please explain it for me?
Array
(
[Errors] => Array
(
[0] => Array
(
[Receiver] =>
[Category] => Application
[Domain] => PLATFORM
[ErrorID] => 520003
[ExceptionID] =>
[Message] => Authentication failed. API credentials are incorrect.
[Parameter] =>
[Severity] => Error
[Subdomain] => Application
)
)
)
thank you
This error message is the result of incorrect credentials being passed. You would want to make sure the credentials you are passing are correct. Note, if you are copying them from the PayPal website directly, I would recommend copy and pasting them into a text editor then copy and paste from there to your code to avoid leading or trailing spaces from occurring when pasting the information.
If your credentials are correct I would recommend reviewing your code to ensure that these credentials are not being changed or modified when being passed over to PayPal.
One thing thing you can try is if your using the sandbox for the purpose of this testing, I would recommend attempting to run it in Live mode as there can be issues occasionally with certain functions running on the sandbox environment.

GraphMethodException - Unsupported get request at

I have two Debian-systems. With both I access the Facebook-API via Perl(Facebook::Graph).
On the first system this works perfectly, on the other system I ran into following problem.
Could not execute request (https://graph.facebook.com): GraphMethodException - Unsupported get request at /usr/local/share/perl/5.10.1/Facebook/Graph/Response.pm line 40
Response.pm:
[...]
has response => (
is => 'rw',
isa => 'HTTP::Response',
required=> 1,
);
[...]
ouch $response->code, 'Could not execute request ('.$response->request->uri->as_string.'): '.$message, $response->request->uri->as_string;
[...]
I know it has something to do with my ssl-libs, but I cannot figure out where the problem is. I reinstalled multiple times the IO:Socket:SSL and SSLeay.
Every help is welcome,
enzo
Don't know if this helps, but came on here looking for help with 'graphMethodException' when trying to access this page: http://graph.facebook.com/doodleembroidery (which works fine now).
Have just tracked it down to the page's country permissions. She didn't realise she had set restrictions when she created the page, now she's removed them the link works fine!