代码之家  ›  专栏  ›  技术社区  ›  Luis Rodriguez Sanchez

如何将这个cURL转换为PHP cURL?

  •  -2
  • Luis Rodriguez Sanchez  · 技术社区  · 2 年前

    什么是将其作为PHP卷曲的最佳方式?

      curl --location --request POST 'https://identity.mypayquicker.com/core/connect/token' 
        --header 'Authorization: Basic {token}' 
        --header 'Content-Type: application/x-www-form-urlencoded' 
        --data-urlencode 'grant_type=client_credentials' 
        --data-urlencode 'scope=client_side_operation card{{pAddressForClientSideOperations}{user-token}{clientSessionTokenAllowedOrigin}'",
              "language": "curl",
              "name": "Example Request"
            }
          ]
        }
    
    1 回复  |  直到 2 年前
        1
  •  0
  •   AndreC23    2 年前

    试试这个:

    $curl = curl_init();
    curl_setopt_array($curl, array(
     CURLOPT_URL => 'https://identity.mypayquicker.com/core/connect/token',
     CURLOPT_RETURNTRANSFER => true,
     CURLOPT_ENCODING => '',
     CURLOPT_MAXREDIRS => 10,
     CURLOPT_TIMEOUT => 0,
     CURLOPT_FOLLOWLOCATION => true,
     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
     CURLOPT_CUSTOMREQUEST => 'POST',
     CURLOPT_POSTFIELDS => 'grant_type=client_credentials&scope=client_side_operation%20card%7B%7BpAddressForClientSideOperations%7D%7Buser-token%7D%7BclientSessionTokenAllowedOrigin%7D\'',
     CURLOPT_HTTPHEADER => array(
       'Authorization: Basic {token}',
       'Content-Type: application/x-www-form-urlencoded'
     ),));
    
    
    $response = curl_exec($curl);
    curl_close($curl);
    echo $response;
    

    您可以使用 Postman .