“PHP -API -Methode Post” Code-Antworten

PHP -API -Methode Post

<?php
header('Access-Control-Allow-Origin: *');

header('Content-Type: application/json; charset=UTF-8');

header("Access-Control-Allow-Methods: POST");

header("Access-Control-Max-Age:3600");

header("Access-Control-Allow-Headers:*");
mounir zx

Senden Sie Daten an API PHP

<?php
//The url you wish to send the POST request to
$url = $file_name;

//The data you want to send via POST
$fields = [
    '__VIEWSTATE '      => $state,
    '__EVENTVALIDATION' => $valid,
    'btnSubmit'         => 'Submit'
];

//url-ify the data for the POST
$fields_string = http_build_query($fields);

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); 

//execute post
$result = curl_exec($ch);
echo $result;
?>
Happy Hamster

Ähnliche Antworten wie “PHP -API -Methode Post”

Fragen ähnlich wie “PHP -API -Methode Post”

Weitere verwandte Antworten zu “PHP -API -Methode Post” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen