2017-08-02 40 views
0

我有一個網址,如果我在頭部添加授權密鑰,它顯示我的支付頁面與授權打開URL頭與PHP

我打開這個網址,只有PHP。

如何添加標題鍵並在打開頁面後回顯頁面內容?

我試着使用CURL和file_get_contents,但都沒有工作。

感謝

+0

可能重複[如何設置自定義請求標題鍵與curl和PHP?](https://stackoverflow.com/questions/6805656/how-to-set-custom-request- header-keys-with-curl-and-php) – ifloop

+0

編輯語法,明確標題 – Cyril

回答

0

我建議使用一個複雜的圖書館要做到這一點,就像狂飲:在請求

//設置各種標題:

http://docs.guzzlephp.org/en/stable/

你可以設置標題這樣

$client->request('GET', '/get', [ 
    'headers' => [ 
     'User-Agent' => 'testing/1.0', 
     'Accept'  => 'application/json', 
     'X-Foo'  => ['Bar', 'Baz'] 
    ] 
]);