首頁 > 後端開發 > php教程 > 騰訊物件儲存PHP實踐之上傳 php 創建物件 php物件導向練習題 php json對

騰訊物件儲存PHP實踐之上傳 php 創建物件 php物件導向練習題 php json對

WBOY
發布: 2016-07-29 08:50:46
原創
1080 人瀏覽過

貼程式碼先

<code><span><?php</span><span>$file_name</span> = <span>'test.jpg'</span>;
<span>$upload_url</span> = <span>'web.file.myqcloud.com/files/v1/10039609/wechat/cover/'</span> . <span>$file_name</span>;
<span>$exp</span> = time() + <span>600</span>;
<span>$sign</span> = <span>'a=10039609&b=wechat&k=AKIDqybsVwxcwSeGYJTsLElPdjgFGa5aPGso&e='</span> . <span>$exp</span> . <span>'&t='</span> . time() . <span>'&r='</span> . rand() . <span>'&f=/10039609/wechat/cover/'</span> . <span>$file_name</span>;
<span>$sign</span> = base64_encode(hash_hmac(<span>'SHA1'</span>, <span>$sign</span>, <span>'prbaqNGhrNinShbRWXqfT10wpCFs68hu'</span>, <span>true</span>) . <span>$sign</span>);
<span>$post_data</span> = [
    <span>'op'</span> => <span>'upload'</span>,
    <span>'filecontent'</span> => file_get_contents(<span>'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo_top_ca79a146.png'</span>),  <span>// baidu logo</span>];
<span>$header</span> = [
    <span>'Content-Type: multipart/form-data'</span>,
    <span>'Authorization: '</span> . <span>$sign</span>,
];


<span>$ch</span> = curl_init(<span>$upload_url</span>);
curl_setopt(<span>$ch</span>, CURLOPT_POST, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_HTTPHEADER, <span>$header</span>);
curl_setopt(<span>$ch</span>, CURLOPT_RETURNTRANSFER, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_POSTFIELDS, <span>$post_data</span>);
<span>$res</span> = curl_exec(<span>$ch</span>);

<span>echo</span><span>'<pre class="brush:php;toolbar:false">'</span>;
print_r(json_decode(<span>$res</span>, <span>true</span>));</span></code>
登入後複製
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介紹了騰訊物件儲存PHP實作之上傳,包括了php,物件方面的內容,希望對PHP教學有興趣的朋友有幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板