亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我怎樣才能從拉拉維爾5.3的咕嚕聲中得到回應

我怎樣才能從拉拉維爾5.3的咕嚕聲中得到回應

PHP
慕哥6287543 2022-09-12 13:00:14
我試試像這樣:$client = new Client();$res = $client->request('POST', 'https://api.orange.com/smsmessaging/v1/outbound/tel:+phone/requests/', [            'headers' => [                'Accept' => 'application/json',                'Content-Type' => 'application/json',                'Authorization'=>'Bearer '.$token,                /*'Content-Type' => 'application/x-www-form-urlencoded',*/            ],            /*'form_params' => $body ,*/            'json' => [                'outboundSMSMessageRequest'=>[                'address'=> 'tel:+$phone',                'senderAddress'=>'tel:+phone_rec',                'outboundSMSTextMessage'=>[                     'message'=> 'Hello test!'                ]            ]],            'debug'   => true,            'verify' => false,                ]        );        $res->getStatusCode();        // 200        $res->getHeader('content-type');        // 'application/json; charset=utf8'        $res->getBody();執行時,結果是錯誤curl_setopt_array():不能將輸出類型的流表示為 STDIO FILE* 如何獲取響應?我在郵遞員中嘗試,它的成功得到回應但是我嘗試使用咕嚕聲,它失敗了
查看完整描述

2 回答

?
慕村9548890

TA貢獻1884條經驗 獲得超4個贊

您可以嘗試以下代碼:


try {

    $client = new Client();

    $token = 'token';

    $res = $client->request('POST', 'https://api.orange.com/smsmessaging/v1/outbound/tel:+phone/requests/', [

            'headers' => [

                'Content-Type' => 'application/json',

                'Authorization'=>'Bearer '. $token,

            ],

            'json' => [

                'outboundSMSMessageRequest'=>[

                    'address'=> "tel:youre-phone",

                    'senderAddress'=>'tel:+phone_rec',

                    'outboundSMSTextMessage'=>[

                        'message'=> 'Hello test!'

                    ]

                ]],

            'debug'   => true,

            'verify' => false,

        ]

    );

    echo $res->getBody();

} catch ( \GuzzleHttp\Exception\ClientException $exception ) {

    echo $exception->getResponse()->getBody();

}


查看完整回答
反對 回復 2022-09-12
?
猛跑小豬

TA貢獻1858條經驗 獲得超8個贊

我這樣解決了


 $requestContent = [

            'headers' => [

                'Accept' => 'application/json',

                'Content-Type' => 'application/json',

                'Authorization'=>'Bearer '.$token,

            ],

            'json' => [

                'outboundSMSMessageRequest'=>[                        

                'address'=> "tel:youre-phone",

                'senderAddress'=>'tel:+phone_rec',

                    'outboundSMSTextMessage'=>[

                        'message'=> 'Hello test !'

                    ]

                ]

            ]

        ];

        try {

            $client = new Client();

            $res = $client->request('POST', 'https://api.orange.com/smsmessaging/v1/outbound/tel:+phone_rec/requests/', $requestContent);

            $response = json_decode($res->getBody());

            dd($response);

        } catch (RequestException $re) {


        }


查看完整回答
反對 回復 2022-09-12
  • 2 回答
  • 0 關注
  • 92 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號