I am testing facebook business manager API. https://developers.facebook.com/docs/marketing-api/business-manager-api.
I am testing (creating business manager API)
curl \
-F "name=Pomni Media" \
-F "vertical=ADVERTISING" \
-F "primary_page=<PAGE_ID>" \
-F "timezone_id=1" \
-F "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<USER_ID>/businesses" with a test user.
I added postman
POST https://graph.facebook.com/v2.7/125157388313921/businesses
name : xxxx xxxx
vertical: ADVERTISING
primary_page: 2076479342635006
timezone_id: 1
access_token: EAAcikSwak2oBAI3...
appsecret_proof: 0db84ee1ded55f9ce0ef4a9d91449940014...
And it's result is
{
"error": {
"message": "(#200) Permissions error",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "FQmaUMdrdV3"
}
}
Permission of above user 125157388313921 is
"user_birthday",
"user_religion_politics",
"user_relationships",
"user_relationship_details",
...
"user_managed_groups",
"manage_pages",
"pages_manage_cta",
"pages_show_list",
"publish_pages",
"read_page_mailboxes",
"ads_management",
"ads_read",
"status": "granted"
"business_management",
"public_profile"
Gave all permissions.
And the the facebook app has business manager available level.
I am working with this issue for 5 days, but not success yet.
Any kind of hint will appreciate!
UPDATE: the test user 125157388313921 was created by this api.
https://graph.facebook.com/APP_ID/accounts/test-users?installed=true&name=XXX+XXX&permissions=public_profile,user_friends,email,...,pages_manage_cta,pages_manage_leads,ads_read,ads_management,business_management&method=post&access_token=XXXX
I tried to login at business.facebook.com as test user.
It said that "You are signed in to Facebook with a test user. Ad Manager is not available with this type of access, To use Business Manager sign in with your personal Facebook account", I tried with real user with permission business_manager and successed.
Related
Currently, I am developing a messenger bot. For this purpose, I created a facebook app from facebook developer platform.
Now I need to subscribe facebook pages to my app using graph API, so for any message from the page, I can respond from my server.
I find one in Graph API Doc.
When I try it in the graph API explorer, I am encountering an error.
I followed the following steps:
1. Create a new app and page.
2. Get the page access token from my app.
3. In graph api explorer, Select my desired facebook app(newly created) from the drop-down menu.
5. When I was getting the user access token, made sure, I took permission for both 'publish_pages' and 'manage_pages'
6. Replaced the {page-id} with 'page access token'
I am getting this error:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: EAAfIhxeHRsYBAD3VNK3BzOqkyhxOL8aZBPnUVZA94olvxYrZA93rNGKwUIJFFhS91ogEbBBlGQJxYGSyJe5I1dNntxsPnqNYFkoI1NcEroa4TunvZCWZAZA06U0UcpvUu5HgBIifGqZCWTDcUH6sCe7BCWdljg5LU7OjwbRgyLe2nCILijnuGqH",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "BUv80nDC3jo"
}
}
I sent this code from graph API Explorer:
curl -i -X GET \
"https://graph.facebook.com/v3.1/EAAfIhxeHRsYBAD3VNK3BzOqkyhxOL8aZBPnUVZA94olvxYrZA93rNGKwUIJFFhS91ogEbBBlGQJxYGSyJe5I1dNntxsPnqNYFkoI1NcEroa4TunvZCWZAZA06U0UcpvUu5HgBIifGqZCWTDcUH6sCe7BCWdljg5LU7OjwbRgyLe2nCILijnuGqH/subscribed_apps?access_token=EAAfIhxeHRsYBAD8dPXQ6jR06FPFhsECXlALtumbecpEV1iZAk1BRFd580J3NEZBrH8mmn7DWZA9NqlefpskmpMjbZA7HrmdmLVhWmOsHOHzVS1nHLNizqX8ODAItZARTiIig34NZCbXnfwOyRqewiKvnh6fMIwEA4sVICGtFTEJXdsVUiTkZAkDrAI9pbZAAu5KQW5f6ZAktXvQZDZD"
FULL DEBUG INFORMATION:
==== Query
curl -i -X GET \
"https://graph.facebook.com/v3.1/EAAfIhxeHRsYBAD3VNK3BzOqkyhxOL8aZBPnUVZA94olvxYrZA93rNGKwUIJFFhS91ogEbBBlGQJxYGSyJe5I1dNntxsPnqNYFkoI1NcEroa4TunvZCWZAZA06U0UcpvUu5HgBIifGqZCWTDcUH6sCe7BCWdljg5LU7OjwbRgyLe2nCILijnuGqH/subscribed_apps?access_token=<access token sanitized>"
==== Access Token Info
{
"perms": [
"manage_pages",
"pages_manage_instant_articles",
"pages_show_list",
"publish_pages",
"read_page_mailboxes",
"pages_messaging",
"pages_messaging_phone_number",
"pages_messaging_subscriptions",
"public_profile"
],
"user_id": 1077587462403179,
"app_id": 2190807377856198
}
==== Parameters
- Query Parameters
{}
- POST Parameters
{}
==== Response
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: EAAfIhxeHRsYBAD3VNK3BzOqkyhxOL8aZBPnUVZA94olvxYrZA93rNGKwUIJFFhS91ogEbBBlGQJxYGSyJe5I1dNntxsPnqNYFkoI1NcEroa4TunvZCWZAZA06U0UcpvUu5HgBIifGqZCWTDcUH6sCe7BCWdljg5LU7OjwbRgyLe2nCILijnuGqH",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "BUv80nDC3jo"
}
}
==== Debug Information from Graph API Explorer
- https://developers.facebook.com/tools/explorer/2190807377856198?method=GET&path=EAAfIhxeHRsYBAD3VNK3BzOqkyhxOL8aZBPnUVZA94olvxYrZA93rNGKwUIJFFhS91ogEbBBlGQJxYGSyJe5I1dNntxsPnqNYFkoI1NcEroa4TunvZCWZAZA06U0UcpvUu5HgBIifGqZCWTDcUH6sCe7BCWdljg5LU7OjwbRgyLe2nCILijnuGqH%2Fsubscribed_apps&version=v3.1```
[1]: https://developers.facebook.com/tools/explorer/?method=GET&path=%7Bpage-id%7D%2Fsubscribed_apps&version=v3.1
I am new to Google Cloud. I want to upload an image to my Bucket.
I did it successfully from the GCP Console and GCP Shell. However, I am unable to do it using REST Endpoint using API-KEY.
Here is my URL.
https://www.googleapis.com/upload/storage/v1/b/[MY_BUCKET]/o?uploadType=media&name=myhero&key=[MY_API-KEY]
I am getting the following message
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Anonymous caller does not have storage.objects.create access to [MY_BUCKET]/myhero.",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Anonymous caller does not have storage.objects.create access to [MY_BUCKET]/myhero."
}
}
This is because the bucket currently does not allow any way to allow users with the API-KEY even though the API-KEY allows the user of this key to upload an object to the bucket.
What should I do
1) if I want to go with the API-key way.
2) if I want to go with service-account way. What is the best way to generate Authorisation token? I have come till this point
{"alg":"RS256","typ":"JWT"}.
{
"iss":"761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5#developer.gserviceaccount.com",
"scope":"https://www.googleapis.com/auth/prediction",
"aud":"https://www.googleapis.com/oauth2/v4/token",
"exp":1328554385,
"iat":1328550785
}.
But I am unable to generate {Base64url encoded signature} as I am unable to figure out the private and public keys...
You are getting “anonymous caller” because you are not properly authenticated. You can authenticate using a bearer token instead of the API-KEY.
You can run the following script:
BUCKET=<BUCKET_NAME>
OBJECT=<OBJECT>
TOKEN=$(gcloud auth print-access-token)
curl "https://www.googleapis.com/upload/storage/v1/b/$BUCKET/o?uploadType=media&name=$OBJECT" -H"Authorization: Bearer $TOKEN" -H'Content-Type: image/jpg' --data-binary #$OBJECT
I am getting this rather unhelpful error and it seems to occur for a large variety of things based on the SO posts. So here I am.
I went here https://apps.dev.microsoft.com, logged in and created a new App. I generated a secret and stored it for later on a post-it note... I granted "Group.ReadWrite.All" under "Delegate" as the create channel API doc says I should. I left everything else in the App as default.
I then do a token request like so:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
"https://login.microsoftonline.com/$TENANT/oauth2/v2.0/token" \
-d "client_id=$APP_ID" -d "scope=https%3A%2F%2Fgraph.microsoft.com%2F.default" \
-d "client_secret=$PASSWORD" -d "grant_type=client_credentials"
which gives me this mess:
{"token_type":"Bearer","expires_in":3600,"ext_expires_in":0,"access_token":"BIG_LONG_TOKEN"}
I then take that token and stuff it into my Authorization header and make the call to create the channel:
curl "https://graph.microsoft.com/beta/groups/$TENANT/channels" \
-H "Content-type: application/json" \
-H "Authorization: Bearer $BIG_LONG_TOKEN" \
-d '{
"displayName": "mynewchannel",
"description": "Channel Description"
}'
But this results in tears and this:
{
"error": {
"code": "",
"message": "Authorization has been denied for this request.",
"innerError": {
"request-id": "c572f6df-7537-4a53-aefc-fcc8c71e2037",
"date": "2018-04-17T23:46:50"
}
}
}
I am not sure what I'm missing, but hopefully it's obvious to someone else...
EDIT: Interestingly, if I set TOKEN to garbage, I get a more helpful answer, but this indicates my TOKEN is at least mostly ok and it is more of a authorization rather than an authentication issue
TOKEN=garbage
curl -X GET "https://graph.microsoft.com/beta/groups/$TENANT/channels" -H "Content-type: application/json" -H "Authorization: Bearer $TOKEN"
Results in
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "CompactToken parsing failed with error code: 80049217",
"innerError": {
"request-id": "166cb22b-c135-45e9-9f23-0e73bc68475d",
"date": "2018-04-18T00:20:47"
}
}
}
I went here https://apps.dev.microsoft.com, logged in and created a new App. I generated a secret and stored it for later on a post-it note...
According to Create Channel Rest API document, Application type permission is not supported. So you get the error information Authorization has been denied for this request.
Delegated permissions are used by apps that have a signed-in user present. For these apps either the user or an administrator consents to the permissions that the app requests and the app is delegated permission to act as the signed-in user when making calls to Microsoft Graph. Some delegated permissions can be consented to by non-administrative users, but some higher-privileged permissions require administrator consent.
As Wajeed - MSFT mentioned that you could use Graph explorer with your account login to have a try.
Note: APIs under the /beta version in Microsoft Graph are in preview and are subject to change. Use of these APIs in production applications is not supported.
I need to send private message from my page (i am the admin) to user who already contacted my page
My reference on that this link
https://developers.facebook.com/docs/messenger-platform/send-api-reference
I am testing this feature via Facebook Graph Explorer
https://developers.facebook.com/tools/explorer
Using version V2.9
Request:
curl -X POST -H "Content-Type: application/json" -d '{
"recipient": {
"id": "USER_ID"
},
"message": {
"text": "hello, world!"
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN"
i replace the USER_ID with my id and access token of page i am admin of
But my response is:
{
"error": {
"message": "(#100) No matching user found",
"type": "OAuthException",
"code": 100,
"error_subcode": 2018001,
"fbtrace_id": "AeMT8VK2SbX"
}
}
I know it is required special permission pages_messaging so i am testing this feature using Facebook application Graph API Explorer not my application because it is not approved yet to use this permission
Any idea why i got this error ?
I've already configured adMob for my Android apps and have no problem with that.
Right now I'm looking for any way to check my apps earnings (if possible for each of the apps separately) in any given moment.
Somebody knows if there's any API, library or Web Service I can use to access my AdMob account and get info about my apps' statistics and so on ?
I've already checked the official APK but it seems only intended to show the ads in your app and nothing else.
Thanks in advance
I answer myself.
I was doing some research, and I found that after the recent changes on AdMob, and the migration to AdSense, you must use the AdSense API to get this info.
In particular, each Android app is associated with a "adunit" id, so if you want to check the info of any particular app you might use:
https://developers.google.com/adsense/management/v1.4/reference/accounts/reports/generate
with the following data:
accountId = your Publisher ID (pub-XXXXXXX)
startDate and endDate = The interval of dates you want to check
dimension = AD_UNIT_ID
metric = EARNINGS
With this query you'll have the required info, separated by App.
You get the results in JSON form.
There is an AdMob API available to get the AdMob specific data.
It provides a possibility to generate network and mediation reports available. It could be as simple as:
curl -X POST https://admob.googleapis.com/v1/accounts/<your_publisher_id>/mediationReport:generate \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
--data #- << EOF
{
"report_spec": {
"date_range": {
"start_date": {"year": 2020, "month": 4, "day": 1},
"end_date": {"year": 2020, "month": 4, "day": 1}
},
"dimensions": ["AD_SOURCE", "AD_UNIT", "PLATFORM"],
"metrics": ["ESTIMATED_EARNINGS"]
}
}
EOF
.net: https://developers.google.com/api-client-library/dotnet/apis/admob/v1
java: https://github.com/googleapis/google-api-java-client-services/tree/master/clients/google-api-services-admob/v1
Get an Oauth2.0 access token
With oauth2l
install: https://github.com/google/oauth2l
oauth2l header --json <path_to_secret_json> https://www.googleapis.com/auth/admob.report
path_to_secret_json - is one from the credentials page on the google cloud console.
With curl
Replace the oauth2_client_id with the one you have in your “Cloud project credentials - OAuth 2.0 client IDs” page. (https://console.developers.google.com/apis/credentials?project=)
https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadmob.report&response_type=code&client_id=&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob
Open this link in incognito browser mode;
Follow the instruction, and accept the consonant screen with AdMob publisher's account;
Copy the code, it would be needed for the following request:
curl -L \
-d "client_id=<oauth2_client_id>" \
-d "client_secret=<oauth2_secret>" \
-d "grant_type=authorization_code" \
-d "code=<sign_in_code_from_the_previous_step>" \
-d "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \
https://accounts.google.com/o/oauth2/token
oaut2_client_id and oauth2_secret can be found on the OAuth 2.0 client Id page.
Response:
{
"access_token": "<access_token>",
"expires_in": 3600,
"refresh_token": "<refresh_token>",
"scope": "https://www.googleapis.com/auth/admob.report",
"token_type": "Bearer"
}