我需要下面的代码PHP curl 请求到远程服务器。我无法做到这一点,没有从谷歌获得源代码curl -X贴片
sf6xfgos1#
一些php等价物可以是:使用 curl :
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.telnyx.com/messaging/numbers/'.$tn, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'PATCH', CURLOPT_POSTFIELDS =>'{"profile_id":"string","msg_product":["A2P","P2P"]}', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Accept: application/json', 'x-api-token: API_TOKEN', 'x-api-user: API_USER' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
或者用狂饮:
<?php $client = new Client(); $headers = [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'x-api-token' => 'API_TOKEN', 'x-api-user' => 'API_USER' ]; $body = '{ "profile_id": "string", "msg_product": [ "A2P", "P2P" ] }'; $request = new Request('PATCH', 'https://api.telnyx.com/messaging/numbers/'.$tn, $headers, $body); $res = $client->sendAsync($request)->wait(); echo $res->getBody();
1条答案
按热度按时间sf6xfgos1#
一些php等价物可以是:
使用 curl :
或者用狂饮: