Non-Facebook-page ads in newsfeed - facebook-ads-api

I'm wondering if there is a possibility to create an off-site ad (creative type 1) and place it in newsfeed? I know this wasn't the case so far and that it's not available via Ad Manager/Power editor, but I'm wondering if there is a way to do it via API.
If not, is there a work-around i.e. ability to create an "ad" with title, image and body that can appear in newsfeed but without any Facebook Page? (Although it seems I'm repeating myself).
By the way, when trying to target type 1 creative to "desktopfeed" I'm getting the following error: {"error":{"type":"Exception","message":"There are no valid formats in which your ad will deliver.","code":1487569}}.
This is merely for people who happen to be googling for this error (as I have before posting this).
And the call that produced it:
https://graph.facebook.com/act_xxxxxxxx/adgroups?method=post&access_token=xxxxx&name=testing newsfeed availability&campaign_id=6013832871175&targeting={"countries":["US"],"age_min":13,"broad_age":1,"page_types":["desktopfeed"]}&bid_type=CPC&bid_info={"CLICKS":2}&adgroup_status=ACTIVE&creative={"type":1,"link_url":"http:\/\/www.xxxxxxx.com","title":"testing newsfeed","body":"testing newsfeed","image_hash":"edacffeeb479e931d11eb062decfee7f"}&redownload=1
Thank you,
Dan

All offsite ads in newsfeed need to be related to a Facebook Page, however they do not have to actually be published on the page.
You should create an unpublished page, it's the same as creating a standard page post but just setting published=1 - e.g.:
curl -F 'message=Book your trip to Alaska'\
-F 'link=http://example.com'\
-F 'picture=http://imageurl.com/image'\
-F 'published=0'\
-F 'access_token=PAGE_TOKEN'\
https://graph.facebook.com/{page_id}/feed
Then create a adcreative from this:
curl \
-F "name=sample creative" \
-F "type=27" \
-F "object_id=ID_OF_POST" \
-F "auto_update=true" \
-F "access_token=_____" \
"https://graph.facebook.com/act_12345678/adcreatives"
See the documentation for unpublished page posts for more details.

Related

Is there a way to get a list of projects and API calls associated with a user's Google Workspace account?

I'm performing a large clean up of Google Workspace accounts and I'd like to programmatically determine whether any of the accounts have projects associated with them, and if so, when the last API calls associated with that project were made. Is there any way to do this programmatically via the Google Admin (or some other) APIs? Thank you
Yes... probably ;-)
This is a naive solution and I will be interested to see better ways to do this.
Please run this on a subset of your Projects and Users to ensure it addresses your need
For you to consider:
You write "Projects" but identities can be bound to many Google Cloud resources (Organizations, Folders, Buckets etc.) too
How many Projects and Users are there?
serviceAccount: should be excluded but what about other identities?
We'll filter by log entries for user: (?) currently in a Project Policy.
Org Admin
You'll need to use an Org Admin identity.
List all Projects
PROJECTS=$(\
gcloud projects list --format="value(projectId)")
for PROJECT in ${PROJECTS}
do
echo "Project: ${PROJECT}"
...
done
Get each Project's Policy's user:
Filter the policy by members of the form user:{email}
Extract the value {email} from user:{email}
USERS=$(\
gcloud projects get-iam-policy ${PROJECT} \
--flatten="bindings[].members[]" \
--filter="bindings.members:user" \
--format="value(bindings.members.split(\":\").slice(1:))")
echo "Users: ${USERS}"
Filter Audit Logs actually Admin Activity Logs
Grep the activity logs for the last 30 days for the most recent (!) log entry for this user.
for USER in ${USERS}
do
echo "User: ${USER}"
FILTER="
logName=\"projects/${PROJECT}/logs/cloudaudit.googleapis.com%2Factivity\"
protoPayload.authenticationInfo.principalEmail=\"${USER}\"
"
LOG=$(gcloud logging read "${FILTER}" \
--project=${PROJECT} \
--freshness="30d" \
--order=desc \
--limit=1)
printf "Log:\n%s" "${LOG}"
done

AMO CI always gives Duplicate add-on ID found

I'm currently trying to automate updates of my web extension in my build pipeline with this API / endpoint https://addons.mozilla.org/api/v3/addons.
So the actual command that I'm using looks like this:
curl "https://addons.mozilla.org/api/v3/addons/" -g -XPOST --form "upload=#dist/firefox/psono.firefox.PW.zip" -F "version=1.0.17" -H "Authorization: JWT ABCDEFG..."
(documentation here http://addons-server.readthedocs.io/en/latest/topics/api/signing.html#uploading-without-an-id )
I'm now where I always get (after a lot of tries and errors with the authentication):
{"error":"Duplicate add-on ID found."}
I have in my manifest this:
"manifest_version": 2,
"name": "psono.PW",
"description": "Psono Password Manager",
"version": "1.0.17",
... alot of other stuff ...
"applications": {
"gecko": {
"id": "{3dce78ca-2a07-4017-9111-998d4f826625}"
}
}
If I remove this "applications" attribute, then it passes, but it creates a new extension instead of updating the existing one. I already diffed the manifest of my existing extension and my new one, and besides some formatting of the JSON and the obvious difference of the version attribute, they look identical.
What am I missing, that the AMO API cannot actually match my update with my existing extension?
While I have not tested it, you are clearly sending the request to the URL which is for WebExtensions without an ID rather than the URL which is for uploading a new version of your add-on with an ID. AMO uses add-on IDs to match the add-on to the currently existing one. The only time a WebExtension does not have an ID is the first time you upload a new extension to AMO (and you have chosen not to assign an ID yourself during development).
After you have uploaded your add-on to AMO for the first time and the WebExtension is listed, it has an ID. Thus, I would assume that the documentation is just not 100% clear that uploading without an ID is only for uploading a new WebExtension add-on. The only thing that makes me think that the URL you are using might be intended for WebExtensions with IDs is the error messages which are claimed to be possible, but that list of errors may just be a copy-&-paste from another section.
Uploading a new WebExtensions add-on (without ID):
curl "https://addons.mozilla.org/api/v3/addons/"
-g -XPOST -F "upload=#build/my-addon.xpi" -F "version=1.0"
-H "Authorization: JWT <jwt-token>"
Uploading a new version of an add-on (with ID):
curl "https://addons.mozilla.org/api/v3/addons/#my-addon/versions/1.0/"
-g -XPUT --form "upload=#build/my-addon.xpi"
-H "Authorization: JWT <jwt-token>"
e.g in your your case:
curl "https://addons.mozilla.org/api/v3/addons/{3dce78ca-2a07-4017-9111-998d4f826625}/versions/1.0.17/"
-g -XPUT --form "upload=#dist/firefox/psono.firefox.PW.zip"
-H "Authorization: JWT ABCDEFG..."
I would consider this to be a problem in the documentation for the upload process where the description of the actual use of the WebExtensions-no-ID URL should be clarified.
Please test this to verify that you can upload a new version (including the applications in your manifest.json) using the normal URL for uploading a version. If you confirm that works, I'll submit a pull request to the documentation to make it more clear.
Note: The documentation on MDN, when talking about updating your add-on, states:
It's essential with this workflow that you update the add-on manually using its page on AMO, otherwise AMO will not understand that the submission is an update to an existing add-on, and will treat the update as a brand-new add-on.
However, it should be noted that even that section is talking about updating an add-on without an ID specified in the applications key. Thus, even that documentation is not 100% clear.
Alternate possibilities
If the URL you are using is actually intended for both new WebExtensions without an ID and new versions of already existing WebExtensions with an ID:
You have already uploaded a version 1.0.17 of your add-on. If so, there's a bug which returns the "Duplicate add-on ID found." error rather than having the error text explain that a duplicate version exists for this ID. If this is the case, then I would consider there to also be clarification needed in the documentation that URL is for both WebExtensions with and without an ID: that stating it's without an ID is only with respect to the URL used and parameters passed to the API.
You have not already uploaded a version 1.0.17 of your add-on. If so, there's a bug which does not allow uploading of new versions of an already existing add-on ID. A simple resolution of this is to just declare that this is the intended operation and to change the docuentation to make it clear that the "with ID" URL/PUT should be used instead of the new-add-on, "without ID" URL/POST.

How can I track how many times my script is run?

I have a simple bash script that I want to track how many times it is run. This script will be downloaded and run on other machines so I want to keep dependencies to a minimum.
I want to use curl, but I am unsure of what options there were as far as sending a POST to google analytics or something similar.
Thanks!
You can implement Google Analytics collect POST request with curl in your script. Just add the following :
tracking_id="UA-XXXXXXXX-X"
category="AppCounter"
action="CountAction"
label="CountLabel"
value="1"
curl -d 'v=1&tid='"$tracking_id"'&cid=555&t=event&ec='"$category"'&ea='"$action"'&el='"$label"'&ev='"$value"'' \
-H "User-Agent: AppSpecific" \
"https://www.google-analytics.com/collect"
See the Measurement protocol for Google Analytics

Tyring to update a URL using Curl on Linux

I am trying to update an ticket and I am trying to do that through Linux. Not sure whether it can be done or not, in the way of searching, I found one blogger sharing, where he/she was also trying to update something
He/She has used the below commands to update the URL.
curl -i -u "script-user:password" -X PUT -d "short_description=Update+me" https:/0005000972
I suspect he/she is trying to update the URL with "Update me".
Is that right? or else Can some one explain what that blogger tried to do??
This is a RESTful request. That is a request using standard HTTP methods (GET, POST, PUT, DELETE) to query a server.
-X PUT specifies the method used
-d "...." specifies the data send to the server
https://... (ill formed in your example) is of course the URL of the target server
Usually, the PUT method is used to replace an existing attribute/value on the server. As the concrete parameters and/or methods available are service dependent, I can only guess here that the intend is to update some attribute named short_description to store the value Update Me (URL encoded -- or more formally x-www-form-urlencoded)
Maybe you should first read a little bit more about those topics, and then, if necessary post an other question describing more in details both the target server and the goal you're trying to achieve on it.

Disabling the large file notification from google drive

While downloading zip file(more than 25MB i assume) i am getting the below notification,
Sorry, we are unable to scan this file for viruses.
The file exceeds the maximum size that we scan. Download anyway
in the browser.Is there any option to disable it,so that i can download any large file directly without having to receive such messages as interruption.
Want to know whether any setting is there in the google drive, so that i can disable that broker message.
After spending many countless hours trying to get a direct download link that bypasses the virus scan I finally figured it out by accident. A URL in the format below along with your Google API key will bypass the virus scan. I could not find this documented anywhere (here is the official doc) so use at your own risk as future updates might break it. https://www.googleapis.com/drive/v3/files/fileid/?key=yourapikey&alt=media
You can also use the authorization access token from google oauth instead of the apikey.
Obsolete: this approach no longer works after August 31, 2016
I found that the following pattern allows to disable the large file notification:
https://googledrive.com/host/file-id
I think anyone knows how to find the file-id for Google Drive file.
Please keep in mind that this method works only if file is shared with "Public on the web" option.
But this feature is deprecated and will stop working after August 31, 2016: http://googleappsdeveloper.blogspot.com/2015/08/deprecating-web-hosting-support-in.html
I don't believe there is any longer a way to bypass Google Drive's warning that a file is too big to be scanned for viruses.
At one time Google Drive had web hosting support via webViewLink URLs that look like googledrive.com/host/[doc id]. But that feature is deprecated and will stop working after August 31, 2016.
http://googleappsdeveloper.blogspot.com/2015/08/deprecating-web-hosting-support-in.html
https://developers.google.com/drive/v2/web/publish-site
use zip-extractor to download file and extract to your Google Drive. It's offered as an option at the website you found the link at. You have to be logged in at Google Drive for this to work.
A better alternative is to use a Google Cloud Bucket.
Open the Cloud Storage browser in the Google Cloud Platform Console.
Create bucket that is Multi-Regional or Regional based on your need.
Upload the file o the bucket and make it public.
Use the public url to download the file using scripts, browser, gcloud commands, wget or curl.
This will work for any file size. Cloud Bucket service is really cheap. Google gives you free credits to start out and the bucket use can be well covered under the free credits.
WGET
export fileid=<file-id>
export filename=combian.rar
wget --save-cookies cookies.txt 'https://docs.google.com/uc?export=download&id='$fileid -O- \
| sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1/p' > confirm.txt
wget --load-cookies cookies.txt -O $filename \
'https://docs.google.com/uc?export=download&id='$fileid'&confirm='$(<confirm.txt)
You can bypass preview, virus scan, AND get the correct file name if you simply use the following link convention:
https://drive.google.com/uc?export=download&confirm=yTib&id=FILE_ID
where the google drive file id replaces FILE_ID.
Thanks,
Mick
Well you can try "Download anyway"
If that doesn't work I have found with Gmail that by changing the extension to .txt it allows the file to be downloaded/transferred then when downloaded you can change it back to .zip
The way to go is to use the link format Mick suggested:
https://drive.google.com/uc?export=download&confirm=CONFIRM_CODE&id=FILE_ID
The confirm Code ist valid indefinitely for each file. It does not change over time. So far the only way to find out the confirm code (or for that matter the complete link) is to curl https://drive.google.com/uc?export=download&id=FILE_ID and then extract the link under the "download anyway" button, which includes the confirm code.
Cheers.
you must disable virus scan from Chrome, but it will disable virus scan from all activities with the browser. In Chrome Preferences, show Advanced Settings and uncheck "Enable phishing and malware protection".

Resources