Facebook API: publish_stream permission works only once - facebook

I am working on one application based on Web to post on the wall, comment, like and delete post through the API of Facebook. I ask for these permissions in the register step:
***'scope' => 'publish_actions,read_stream,publish_stream'***
and after registration I can do everything: Post on the wall, comment a post, like and delete. But once I logout from my application and then log in again, take the proper token from my database and try to do the same things, I find that I can post on the wall and delete post but when I try to like or comment I found this error:
*Fatal error: Uncaught OAuthException: (#200) Requires publish_stream permission or Requires extended permission:
publish_actions thrown in...*.
But in fact when I asked about the permission of the user to facebook I have this answer:
*Array ( [data] => Array ( [0] => Array ( [installed] => 1 [read_stream] => 1 [status_update] => 1 [photo_upload] => 1 [video_upload] => 1 [create_note] => 1 [share_item] => 1 [publish_stream] => 1 [publish_actions] => 1 ) ) )*
What I am doing wrong? Thanks!

When the user logs into facebook again, you should refresh their token in your database and use the updated version with any API calls you make.

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

Paypal Balance Accounts API - INSUFFICIENT_PRIVILEGES

i'm trying to access paypals accounts using the rest api
i'm making a request to /v2/wallet/balance-accounts/ ( Documentation : https://developer.paypal.com/docs/api/balance-accounts/)
but keep getting the following message:
Array
(
[name] => INSUFFICIENT_PRIVILEGES
[message] => Insufficient privileges for requested resource.
[information_link] =>
[details] => Array
(
[0] => Array
(
[issue] => Insufficient privileges for requested resource.
[code] => INSUFFICIENT_PRIVILEGES
)
)
)
does anyone know from where i can change/add the privileges? i can't find the settings for it
thank you
It says here you must have a business account, and also here (you must be a partner) based on their suggestion here you have an alternative:
https://developer.paypal.com/docs/classic/api/merchant/GetBalance_API_Operation_NVP/
Which is unfortunately not REST
Hope this helps

Facebook SDK API: How to get details on post shares?

I'm using the FB PHP SDK to get info on a post in a page I manage.
So far I can get:
$result = $facebook->api("/123xx");
$result = $facebook->api("/123xx/likes");
$result = $facebook->api("/123xx/comments");
$result = $facebook->api("/123xx/insights");
This gives me a lot of info, but I'm missing details about 'shares'. All I get is
[shares] => Array
(
[count] => 13
)
but no user ids or comments associated with those shares. Is there a way to pull that info with the SDK (or FQL)?
Regarding permissions, my script is asking for 'scope' => 'manage_pages,read_insights' Do I need another param to request this info?
Thanks for any assistance

Fatal error: Uncaught Exception: 102: Session key invalid or no longer valid

Since yesterday (10 december) many of my apps have stopped working with executing facebook calls. For example calls for checking if the loggedin user has liked a page or getting all the albums of the loggedin user. I use the php sdk!
With all my calls I receive :
Fatal error: Uncaught Exception: 102: Session key invalid or no longer valid thrown in /xxxx/ on line yyy
My facebook object is correct and I receive a valid user id with $facebook->getUser();
Example checking if a user is a fan:
$likes = $facebook->api('/'.$user.'/likes/154125631364512&access_token='.$facebook->getAccessToken());
Or example getting all the photo albums from the logged in user (fql):
$fql = "SELECT aid, object_id, cover_pid, name, size FROM album WHERE owner= '".$facebook->getUser()."'";
$userAlbums = $facebook->api(array('method' => 'fql.query', 'query' => $fql));
Or example, getting all the pictures from a album :
$params['fields'] = 'name,source,images,picture,height,width';
$params = http_build_query($params, null, '&');
$data['albumPhotos'] = $facebook->api("/album_object_id/photos?".$params);
All calls worked for weeks and suddenly are broke since the crash from facebook.
Anyone out there has any idea as to why these calls suddenly fail?
Check this: https://developers.facebook.com/bugs/181323008674971?browse=search_50c7385f82da62c58502145 you should update your PHP SDK but even doing this way, i'm still having problems; let's hope that they fix this annoying issue soon.

Why does Facebook Credits callback payments_get_items occasionally not pass user ID?

Our facebook canvas app is having this problem where now, several times a day, the credits callback is passing a signed_request with the following contents:
Array
(
[algorithm] => HMAC-SHA256
[credits] => Array
(
[order_id] => 9005967273834
[order_info] => "item104"
)
[issued_at] => 1319329443
[user] => Array
(
[country] => do
[locale] => es_LA
[age] => Array
(
[min] => 0
[max] => 12
)
)
)
Notice anything missing? That's right! No user_id, buyer, or receiver is given!
We can't tell facebook what the price or description of an item is without knowing who is receiving the item.
This seems like a bad bug! This problem started happening on Oct 11, 2011
This is definitely an intermittent bug, so the only work-around is to pass the user ID from your own code into the order_info field of the item. Then use that instead of the credits receiver if the user information is missing.
I don't like that I have to do this, but it seems necessary.
I noticed this as well on my app and from what I can see the missing user IDs happen when Facebook indicates an age bracket of min 0 and max 12 years for the user. I assume that this might be the result of under 13 year olds being prevented from making purchases with Facebook credits.
Which makes me wonder what they are doing on Facebook to start with...