https – Website dropping my session when accessing it with iOS Shortcut actions as opposed to curl

I am trying to log on to a website with my credentials using the Shortcuts App on iOS making several HTTP requests. These requests are encapsulated within blocks called “actions”. The name of this HTTP request action is “Get Contents of URL”. It lets you choose between GET, POST, DELETE etc. and let you set header custom header fields as well.
The only downside: You can not access the response header. Hence, if there’s a “Set-Cookie” in the response header, you can’t store it for later use.

My Problem is that the login process is failing with these shortcut actions but it is successful when I perform the login using distinct cURL commands sending the same data. And here’s where I am unsure: Whether it is actually the same data that the cURL commands send.
I copied them from a chrome session in which I logged in to the website (“copy as curl”).

The website is an rwt/rap client, which I have never heard of before. It seems like every interaction on the website (pressing buttons, entering form data) sends a POST with json data structure in the body.
For example, this is the data that’s being sent when leaving the input field for the username after entering it (“myUsername“):

{"head":{"requestCounter":1},"operations":(("set","w4",{"selection":(8,8),"text":"myUsername"}),("notify","w4","FocusOut",{}),("notify","w22","FocusIn",{}),("set","w2",{"activeControl":"w22"}),("set","w1",{"cursorLocation":(525,484),"focusControl":"w22"}))}

The process to login is the following:

  1. Send a http GET to the url and retrieve a 32 char long “jsessionid
    in the response body
  2. Send a http POST to the same url but with
    ;jsessionid=<32characters>” appended to it and retrieve a 6 char
    long “cid” in the response body
  3. Send the username in the request body (in a json data structure) to the same url as in step 2 but with “?cid=<6characters>” appended to it and retrieve a response with {"head":{},"operations":()} in the body signaling success
  4. Send the password in the request body (json structure) to the same url (with jsessionid and cid) and retrieve a response with {"head":{},"operations":()} in the body signaling success
  5. Send a “button Press” for the login button in the request body to the same url retrieve a response with a long json structure in the body that contains instructions on how to generate the UI of the “logged in” website

Oh yeah, and every request that I send has a request counter that I increment in the request body’s json.
But for now I am only concentrating on logging in successfully, which contains of the above 5 requests.

Sending them with cURL: No problem. Using the shortcuts action’s http requests I get an error for the one sending the password (No 4): The error is a 403 with the following text "Forbidden You dont have permission to access /path-to-app/pcterminal;jsessionid<32characters> on this server. Additionally, a 500 Internal Server Error error was encountered while tring to use an ErrorDocument to handle the request."

At first I thought that it has to do with cookies, because the requests that I recorded in chrome had a “Set-Cookie” in the response containing the jsessionid and a settingStore. But I dropped the entire “Cookie” field from the request headers when using the cURL commands.
But the error seems to indicate that before I send the 4th request the server has dropped my session somehow.

How else could I debug this and find out the cause of this?

PHP and Nginx on docker, curl get Connection refused in php container

I am working in a local environment with docker.
I have an nginx web container and a php container which are in the same network.

I build the php container from my own dockerfile (with phpfpm and phpcli); and, the nginx I compose it in a docker-compose from the nginx:stable hub image.

I have 2 projects: a symfony(http://i-r4y.kaiza.lh/) and a drupal(http://i-z4r4.kaiza.lh/) which runs in it. and the symfony exposes an api which have to be consumed by the drupal. The problem is that an error when I call the symfony from the drupal cURL error 7: Failed to connect to i-r4y.kaiza.lh port 80: Connection refused

I thought it was a configuration of the symfony side api route; like it must be public or accept CORS etc …

but in the php container, when I do curl either the symfony or drupal url, I have the same error.

app@kz-php74:/var/www$ curl http://i-r4y.kaiza.lh
curl: (7) Failed to connect to i-r4y.kaiza.lh port 80: Connection refused
app@kz-php74:/var/www$ curl http://i-z4r4.kaiza.lh
curl: (7) Failed to connect to i-z4r4.kaiza.lh port 80: Connection refused

I checked in the php container that the hosts are present in /etc/hosts

app@kz-php74:/var/www$ cat /etc/hosts | grep i-
127.0.0.1   i-r4y.kaiza.lh
127.0.0.1   i-z4r4.kaiza.lh

Here is the docker-compose.yml :

version: '2.4'

services:
  php7.4:
    build:
      context: ../../../dockerfile
      dockerfile: Dockerfile.php
      args:
        PHP_VERSION: 7.4
    container_name: "kz-php74"
    hostname: "kz-php74"
    user: 1000:1000
    working_dir: /var/www
    volumes:
      - "${LOCAL_PATH}/../www:/var/www"
    extra_hosts:
      - "i-r4y.kaiza.lh:127.0.0.1"
      - "i-z4r4.kaiza.lh:127.0.0.1"
    networks:
      - kz_local

  mysql:
    container_name: kz-mysql
    image: mariadb:10.4.0
    volumes:
      - ${LOCAL_PATH}/.data/mariadb:/var/lib/mysql
      - ${LOCAL_PATH}/config/mariadb/conf.d/custom.cnf:/etc/mysql/conf.d/custom.cnf
      - ${LOCAL_PATH}/../www:/var/www
    ports:
      - ${MYSQL_PORT:-3306}:3306
    environment:
      MYSQL_ROOT_PASSWORD: password
    networks:
      - kz_local

  web:
    image: nginx:stable
    container_name: kz-web
    volumes:
      - ${LOCAL_PATH}/config/nginx/conf.d:/etc/nginx/conf.d
      - ${LOCAL_PATH}/../www:/var/www
    ports:
      - 80:80
    networks:
      - kz_local

networks:
  kz_local:
    external: true

The nginx config of drupal:

server {
    listen 80;
    listen (::):80;
    server_name i-z4r4.kaiza.lh;

    root /var/www/i-z4r4/web;

    resolver 127.0.0.11 ipv6=off;
    
    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    # In Drupal 8, we must also match new paths where the '.php' appears in
    # the middle, such as update.php/selection. The rule we use is strict,
    # and only allows this pattern with the update.php front controller.
    # This allows legacy path aliases in the form of
    # blog/index.php/legacy-path to continue to route to Drupal nodes. If
    # you do not have any paths like that, then you might prefer to use a
    # laxer rule, such as:
    #   location ~ .php(/|$) {
    # The laxer rule will continue to work if Drupal uses this new URL
    # pattern with front controllers other than update.php in a future
    # release.
    location ~ '.php$|^/update.php' {
        set $fastcgi_pass "kz-php74:9000";

        fastcgi_split_path_info ^(.+?.php)(|/.*)$;
        # Security note: If you're running a version of PHP older than the
        # latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
        # See http://serverfault.com/q/627903/94922 for details.
        include fastcgi_params;
        # Block httpoxy attacks. See https://httpoxy.org/.
        fastcgi_param HTTP_PROXY "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_intercept_errors on;
        fastcgi_pass $fastcgi_pass;
    }

  ...

}

For symfony:

server {
    listen 80;
    listen (::):80;
    server_name i-r4y.kaiza.lh;

    root /var/www/i-r4y/public;

    resolver 127.0.0.11 ipv6=off;

    location / {
        # try to serve file directly, fallback to index.php
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index.php(/|$) {
        set $fastcgi_pass "kz-php74:9000";

        fastcgi_pass $fastcgi_pass;
        fastcgi_split_path_info ^(.+.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS on;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }
...
}

will anyone have any idea why this is not working?

thanks

curl – Send private message using PHP (userbot)

Basically i am trying to use php and curl to send messages as user.

It’s working half-ish, basically i have gotten it to send a message but whenever i refresh the php again to try to make it send again it doesn’t wanna send again…. and i have no clue why since i don’t understand the discord api that well.

Anyways, here’s my function for sending message:

function sendChannelMessage ($channel, $msg) {
$sessions = file("bot.txt", FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
foreach ($sessions as $session) {
$tag = explode("|", $session);
$authtoken = $tag(1);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://discordapp.com/api/v6/channels/$channel/messages");
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$headers = array();
$headers() = "Connection: keep-alive";
$headers() = "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0";
$headers() = "Content-Type: application/json;charset=utf-8";
$headers() = "Referer: https://discordapp.com/channels/$channel/";
$headers() = "Authorization: $authtoken";
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POST, 1);
$requ3st = array("content" => $msg, "nonce" => $channel);
$requ3st_encoded = json_encode($requ3st);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requ3st_encoded);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
}

And heres what im executing with the function file included:

include 'runme.php';
$c = "channel_id";
echo sendChannelMessage($c, "TEST");

If anyone is more experienced with the discord api and can clarify on this, would be grateful.

Regards.

command line – Explanation /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

I would like to understand exactly what this command does. I know this command installs homebrew on macOS, but I would like to understand the meaning of the syntax:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

For example:

/bin/bash is the path to the bash folder

what about the other parts?

proxy – Android ADB Port forward returns CONNECT aborted with curl

I’m trying to use my phone’s data connection as a proxy on any port on my PC. I’ve enabled the port forward with: adb forward tcp:5001 tcp:8080 and I get 5001 as a response from the adb shell. Different ports i’ve tried:

Now i’m just trying to send a curl request to ipify.org’s api with curl https://api.ipify.org?format=json –proxy 127.0.0.1:8128 but the response I get is curl: (56) Proxy CONNECT aborted, for reference, i’ve tried this with an external proxy and it works fine: curl https://api.ipify.org?format=json –proxy 159.197.253.210:7689 returns {“ip”:”159.197.253.210″} which is exactly what should happen. Pic for reference:

Am I doing something wrong? How do I use my android as a proxy?

How to set CURL options in a Drupal 8 custom migration?

I have a custom migration that needs to get json from a remote url. This works fine in a beta environment outside of ddev but I’m having trouble in my ddev test environment because of SSL on the other end. The only place I can find any Drupal settings, it seems the curl option SSL_VERIFYHOST is set to false, but that’s clearly not happening when my migration tries to run. I’m using migrate, migrate_tools and migrate_plus; I saw that another module, migration_tools, might allow me to set the curl options but I get a dependency error when trying to enable it. Core and modules are all current versions. Any help would be greatly appreciated.

Convert curl to python requests including cookies

Some background details:

We have an internal site which has SSO with 2FA, and also requires client certs.
It has a form which submits a job. I’m trying to automate the process by running it from CLI. So far I have been able to get a job submitted using curl. For it to work I need to extract the cookies from my browser session. So the following curl command is running as expected

curl -b cookies.txt -k --cert cert --key key -F 'field=value'

I now tried to convert the same to a Python requests call. However it looks like it is not getting the cookies. I can see that from the output of script going to the SSO login page. Here is the script I have so far

from requests_toolbelt import MultipartEncoder
import requests
import http.cookiejar

cookies = http.cookiejar.MozillaCookieJar('cookies.txt')
cookies.load(ignore_expires=True)

cert = ('cert','key')

m = MultipartEncoder(
    fields={'field': 'value'}
    )

headers = {
     'Content-Type': m.content_type,
}

r = requests.request('POST', url, data=m,
     headers=headers, cookies=cookies, cert=cert, verify=False)

From what I can i have matched all curl options. But as mentioned it seems to be ignoring the cookies, and tries to run a SSO. Any idea how to get this running? If nothing else works, I would have to run the curl via a subprocess. But i would rather get it going within the Python requests.

Any help/hints much appreciated.

fa.functional analysis – Existence of divergence-free representatives in a Beppo Levi-like curl space

Let us consider the following vector quotient space:

$$ mathring{BL}(operatorname{curl}; mathbb R^3) := { mathbf u in L^2_{text{loc}}(mathbb R^3): operatorname{curl} mathbf u in L^2(mathbb R^3) }/nabla mathring{BL}(mathbb R^3), $$

where

$$ mathring{BL}(mathbb R^3) = { u in L^2_{text{loc}}(mathbb R^3) : nabla u in L^2(mathbb R^3) }^3/mathbb R^3. $$

The motivation for this definition is the fact that the kernel of the seminorm $|mathbf u|_{operatorname{curl}} = int_{mathbb R^3} |operatorname{curl} mathbf u|^2$ consists of gradient fields (distributions). Indeed it can be shown that $(mathring{BL}(operatorname{curl}; mathbb R^3), |cdot|_{operatorname{curl}} )$ is a Hilbert space.

Now, I was wondering if we could prove or disprove that each class has a divergence-free representative.

I would start as follows: fix any class and take a representative $mathbf u$; since $operatorname{div} mathbf u$ generates a bounded functional on $mathring{BL}(mathbb R^3)$ (scalar version) solve

$$ – Delta w = operatorname{div} mathbf u $$

by Riesz’s representation and set $mathbf u^{*} = mathbf u – nabla w$. Then $mathbf u^{*} in (mathbf u)$ and $operatorname{div}mathbf u^{*}= 0$ in the sense of distributions. The problem with this argument is that $operatorname{div} mathbf u$ does not generate such bounded functional if merely $mathbf u in L^2_{text{loc}}$, on the other hand, I would not be happy to require the full $L^2$ summability since $mathring{BL}(operatorname{curl}; mathbb R^3)$ is used precisely when one has global control only on the curl. Maybe some kind of intermediate weight is enough?

Another option could be to somehow argue by density, but I don’t even know if test functions are dense in $mathring{BL}(operatorname{curl}; mathbb R^3)$: I suspect that the density proof requires a sort of Poincaré inequality for the sole curl, which only holds (in bounded domains) if we already have the divergence constraint, besides other conditions.

proxy – Nginx controller in kubernetes cluster is not forwarding curl request to service

My Ingress Controller is not forwarding the request to the service, how can i fix it? I can see that my Ingress is missing addresses, but i do not know why.

I have a Kubernetes Cluster running on a 1 master, 2 worker setup on linux servers. I have a HAProxy forwarding my requests to Nginx Controllers. My complete setup is behind a corporate proxy. The DNS entry is enabled in this corporate proxy.
Requests will get to the nginx controller, but wont be forwarded to the service.
I installed the ingress controller as descibed by many tutorials with the files in https://github.com/kubernetes/ingress-nginx .

I’m new to stack overflow, so if i should give more specific information just let me know. I hope someone can help me with my issue, thank you in advance 😀

My Ingress with missing Address:

Name:             app-ingress
Namespace:        default
Address:
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host                       Path  Backends
  ----                       ----  --------
  test.kubetest.lff.bybn.de
                             /abc   app-service:80 (10.244.2.4:3000)
Annotations:                 kubernetes.io/ingress.class: nginx
Events:                      <none>

Yaml Files of Deployment, Service and Ingress, IngressClass, ConfigMap

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    run: app
  name: app-blue
spec:
  replicas: 1
  selector:
    matchLabels:
      run: app
      version: 0.0.1
  template:
    metadata:
      labels:
        run: app
        version: 0.0.1
    spec:
      containers:
      - name: app
        image: errm/versions:0.0.1
        ports:
        - containerPort: 3000
----



apiVersion: v1
kind: Service
metadata:
  name: app-service
spec:
  selector:
    run: app
    version: 0.0.1
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 3000
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: app-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: test.kubetest.lff.bybn.de
    http:
      paths:
      - path: /abc
        backend:
          serviceName: app-service
          servicePort: 80
---

apiVersion: networking.k8s.io/v1beta1
kind: IngressClass
metadata:
  name: nginx
  # annotations:
  #   ingressclass.kubernetes.io/is-default-class: "true"
spec:
  controller: nginx.org/ingress-controller
---

kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-config
  namespace: nginx-ingress
data:

Curl from outside of the Cluster and Logs from Controller Pod

curl test.kubetest.lff.bybn.de/abc
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    93    0    93    0     0      1      0 --:--:--  0:00:50 --:--:--    26<html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.
</body></html>



E0131 19:44:11.949261       1 reflector.go:138) /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)
E0131 19:45:06.894791       1 reflector.go:138) /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)
E0131 19:45:48.532075       1 reflector.go:138) /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)
10.48.25.57 - - (31/Jan/2021:19:46:35 +0000) "GET /abc HTTP/1.1" 499 0 "-" "curl/7.73.0" "-"
E0131 19:46:37.902444       1 reflector.go:138) /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)
E0131 19:47:15.346193       1 reflector.go:138) /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)
E0131 19:47:48.536636       1 reflector.go:138) /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)
E0131 19:48:21.890770       1 reflector.go:138) /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)

Integração CURL PHP no Braspag

Estou com um projeto do qual o mesmo irá usar a BrasPag e terei que fazer essa integração via API REST. Na documentação deles, aparece dois exemplos JSON e CURL. Vejam:

CURL

--request POST "https://apisandbox.braspag.com.br/v2/sales/"
--header "Content-Type: application/json"
--header "MerchantId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
--header "MerchantKey: 0123456789012345678901234567890123456789"
--header "RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
--data-binary
{  
   "MerchantOrderId":"2017051002",
   "Customer":{  
      "Name":"Nome do Comprador",
      "Identity":"12345678909",
      "IdentityType":"CPF",
      "Email":"comprador@braspag.com.br",
      "Birthdate":"1991-01-02",
      "IpAddress":"127.0.0.1",
      "Address":{  
         "Street":"Alameda Xingu",
         "Number":"512",
         "Complement":"27 andar",
         "ZipCode":"12345987",
         "City":"São Paulo",
         "State":"SP",
         "Country":"BRA",
         "District":"Alphaville"
      },
      "DeliveryAddress":{  
         "Street":"Alameda Xingu",
         "Number":"512",
         "Complement":"27 andar",
         "ZipCode":"12345987",
         "City":"São Paulo",
         "State":"SP",
         "Country":"BRA",
         "District":"Alphaville"
      }
   },
   "Payment":{  
      "Provider":"Simulado",
      "Type":"CreditCard",
      "Amount":10000,
      "Currency":"BRL",
      "Country":"BRA",
      "Installments":1,
      "Interest":"ByMerchant",
      "Capture":true,
      "Authenticate":false,
      "Recurrent":false,
      "SoftDescriptor":"Mensagem",
      "DoSplit":false,
      "CreditCard":{  
         "CardNumber":"4551870000000181",
         "Holder":"Nome do Portador",
         "ExpirationDate":"12/2021",
         "SecurityCode":"123",
         "Brand":"Visa",
         "SaveCard":"false",
         "Alias":"",
         "CardOnFile":{
            "Usage":"Used",
            "Reason":"Unscheduled"
         }
      },
      "Credentials":{  
         "Code":"9999999",
         "Key":"D8888888",
         "Password":"LOJA9999999",
         "Username":"#Braspag2018@NOMEDALOJA#",
         "Signature":"001"
      },
      "ExtraDataCollection":(  
         {  
            "Name":"NomeDoCampo",
            "Value":"ValorDoCampo"
         }
      )
   }
}
--verbose

JSON

{  
   "MerchantOrderId":"2017051001",
   "Customer":{  
      "Name":"Nome do Comprador",
      "Identity":"12345678909",
      "IdentityType":"CPF",
      "Email":"comprador@braspag.com.br",
      "Birthdate":"1991-01-02",
      "IpAddress":"127.0.0.1",
      "Address":{  
         "Street":"Alameda Xingu",
         "Number":"512",
         "Complement":"27 andar",
         "ZipCode":"12345987",
         "City":"São Paulo",
         "State":"SP",
         "Country":"BRA",
         "District":"Alphaville"
      },
      "DeliveryAddress":{  
         "Street":"Alameda Xingu",
         "Number":"512",
         "Complement":"27 andar",
         "ZipCode":"12345987",
         "City":"São Paulo",
         "State":"SP",
         "Country":"BRA",
         "District":"Alphaville"
      }
   },
   "Payment":{  
      "Provider":"Simulado",
      "Type":"CreditCard",
      "Amount":10000,
      "Currency":"BRL",
      "Country":"BRA",
      "Installments":1,
      "Interest":"ByMerchant",
      "Capture":true,
      "Authenticate":false,
      "Recurrent":false,
      "SoftDescriptor":"Mensagem",
      "DoSplit":false,
      "CreditCard":{  
         "CardNumber":"4551870000000181",
         "Holder":"Nome do Portador",
         "ExpirationDate":"12/2021",
         "SecurityCode":"123",
         "Brand":"Visa",
         "SaveCard":"false",
         "Alias":"",
         "CardOnFile":{
            "Usage": "Used",
            "Reason":"Unscheduled"
         }
      },
      "Credentials":{  
         "Code":"9999999",
         "Key":"D8888888",
         "Password":"LOJA9999999",
         "Username":"#Braspag2018@NOMEDALOJA#",
         "Signature":"001"
      },
      "ExtraDataCollection":(  
         {  
            "Name":"NomeDoCampo",
            "Value":"ValorDoCampo"
         }
      )
   }
}

Irei usar o CURL do PHP e para isso estou fazendo dessa forma:

$camposArray = array(
        'Name' => 'Fox Tavares',
        'Identity' => '1111'
    );
   $campos = http_build_query($camposArray);
   $header = array(
       'Content-Type: application/json',
       'MerchantId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
       'MerchantKey: 0123456789012345678901234567890123456789',
       'RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
   );
    $url = 'https://apisandbox.braspag.com.br/v2/sales/';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $campos);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    $resposta = curl_exec($ch);

A minha dúvida é a seguinte. Tanto no JSON, assim como o CURL, o array está dessa forma. Um trecho do código:

"Customer":{  
      "Name":"Nome do Comprador",
      "Identity":"12345678909",
      "IdentityType":"CPF",
      "Email":"comprador@braspag.com.br",
      "Birthdate":"1991-01-02",
      "IpAddress":"127.0.0.1",
      "Address":{  
         "Street":"Alameda Xingu",
         "Number":"512",
         "Complement":"27 andar",
         "ZipCode":"12345987",
         "City":"São Paulo",
         "State":"SP",
         "Country":"BRA",
         "District":"Alphaville"
      },
      ...

Como eu poderia aplicar essa estrutura do array no meu código abaixo? Pois deles começa dessa forma: "Customer":{

$camposArray = array(
        'Name' => 'Fox Tavares',
        'Identity' => '1111'
    );