Posts tagged with javascript

In my meta application with instagram api with instagram login when I define the "Data deletion request URL" the POST request send to my route with following body content

POST /api/delete HTTP/1.1 Host: 26d5-45-8-19-76.ngrok-free.app User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) Content-Length: 166 Accept: */* Accept-Encoding: deflate, gzip Content-Type: application/x-www-form-urlencoded X-Forwarded-For: 2a03:2880:30ff:8:: X-Forwarded-Host: 26d5-45-8-19-76.ngrok-free.app X-Forwarded-Proto: https signed_request=NybldKYslIBJJfCjH9jIE6PI3ohOKimGpB293v1ojeI.eyJ1c2VyX2lk....... 

I can't verify the content using header provided based on the description that provided in following link Data Deletion Request Callback

I did following in the NestJS framwork service

import { Injectable } from '@nestjs/common'; import * as crypto from 'crypto'; @Injectable() export class SignedRequestService {   private readonly secret = 'appsecret'; // Use your app secret here   parseSignedRequest(signedRequest: string): any | null {     const [encodedSig, payload] = signedRequest.split('.', 2);     // decode the data     const sig = this.base64UrlDecode(encodedSig);     const data = JSON.parse(this.base64UrlDecode(payload));     // confirm the signature     const expectedSig = crypto       .createHmac('sha256', this.secret)       .update(payload)       .digest();     if (Buffer.compare(Buffer.from(sig), expectedSig) !== 0) {       console.error('Bad Signed JSON signature!');       return null;     }     return data;   }   private base64UrlDecode(input: string): string {     const base64 = input.replace(/-/g, '+').replace(/_/g, '/');     return Buffer.from(base64, 'base64').toString('utf-8');   } } 

tl;dr: Should there be a sha256_ prefix to city, regon, postal code, country, and should I hash them or not?

---- details I am wondering wether google doesn't consider city, region and postal code a sensitive information or the docs are incomplete. Judging by the second example, I don't need to hash even street address. And yet I believe I should hash everything... [Using smarty in the examples]

                gtag('set', 'user_data', {                     "sha256_email_address": "{hash('sha256', $order_info.email)}",                     "address": {                         "sha256_first_name": "{hash('sha256', $order_info.firstname)}",                         "sha256_last_name": "{hash('sha256', $lastname)}",                         "sha256_street": "{hash('sha256', $address)}",                         "sha256_city":"{hash('sha256', $city)}",                         "sha256_region":"{hash('sha256', $country)}",                         "sha256_postal_code": "{hash('sha256', $zipcode)}",                         "sha256_country": "{hash('sha256', $country)}"                     }                 }); 

**Resources: ** https://support.google.com/analytics/answer/14171598 https://developers.google.com/analytics/devguides/collection/ga4/uid-data

"sha256_city":"{hash('sha256', $city)}", vs "city":"{hash('sha256', $city)}", vs "city":"{$city}",

I am trying to retrieve a list of all pages (business and non-business) that the account has. However, only non-business pages are currently being returned.

First I allow the user to login. He/she gets a Facebook Login popup, where he/she can select the pages. Then I generate a long-lived token, like so:

const response = await axios.get(   "https://graph.facebook.com/v21.0/oauth/access_token",   {     params: {       grant_type: "fb_exchange_token",       client_id: process.env.FB_APP_ID,       client_secret: process.env.FB_APP_SECRET,       fb_exchange_token: fbAccessToken,     },   } ); 

I get a token just fine. I return the token and the client makes an api call to retrieve the pages:

const handleFacebookCallback = async (response: any) => {   if (!response?.id) {     return;   }   setLoading(true);   const { data } = await api.post("/api/integrations/facebook/user", {     userId: user._id,     fbAccessToken: response.accessToken,     fbUserId: response.id,   });   const url = `https://graph.facebook.com/v21.0/${response.id}/accounts?access_token=${data.longLivedToken}`;   const fbResponse = await fetch(url);   const fbData = await fbResponse.json();   setResponseFbPages(fbData.data);   setLoading(false); }; 

Now, I have 3 pages - 2 are business and 1 non-business. Only the non-business pages are getting returned.

I tried to query the /accounts endpoint, and I am expecting to get a full list of pages returned.

I'm attempting to use Meta's OAuth login for a project, however, the dialog is always a complex multi-step process. Several other sites have a simple, 1-click dialog. I noticed that whether I use the SDK or url, it ends up being the same result. Additionally, the url for the 1-click dialog is much longer and always starts with "https://www.facebook.com/privacy/consent/gdp/?params%5Bapp_id%".

1-click Dialog Multi-step Dialog

Ss there any way to get the simpler login dialog on my end, or is it up to Meta?

I tried using both the SDK and a manual login with differing login settings. I also tried adding and removing scopes as well as all the possible auth_types to no avail. I also am testing in live mode/production.

Wanting to track 'Add to Cart' clicks on a WooCommerce store & Google Ads tell me I need to call gtag_report_conversion when any 'Add to cart' button is clicked on the site.

Some buttons are a link <a href="... etc"> using class="add_to_cart_button" - see example page

While other buttons are a <button> tag using class="single_add_to_cart_button" - see example page

I see from Google's instructions that the structure for a link is:

<a onclick="return gtag_report_conversion('http://example.com/your-link');"href="http://example.com/your-link">Add To Cart</a>

And the structure for a <button> tag is:

<button onclick="return gtag_report_conversion('http://example.com/your-link')">Add To Cart</button>

How can I construct a function hook that will create the above link / button tag structure & would it be an action or filter hook? Also, is it possible to use the classes mentioned earlier to define which buttons on the site should be affected by this particular function. The documentation showing what action & filter hooks are available for WooCommerce is here.