我想調用Pho.to API來編輯照片,並且每次嘗試POST時都會得到相同的錯誤。我已經雙倍和三倍檢查了我的app_id
和我的key
,我無法弄清楚我做錯了什麼。我目前使用ARC Chrome擴展來調用這個api,所以我甚至還沒有開始編寫這個部分,我只是試圖從api得到一個真正的迴應,以確保它的工作。錯誤調用Pho.to API
我遵循他們的文檔中的說明以及我可以。這裏的鏈接以供參考:http://developers.pho.to/documentation/sending-requests
這裏是我的API調用:
http://opeapi.ws.pho.to/addtask?APP_ID=<my-app-id>&KEY=<my-key>&SIGN_DATA=910ceb5bdb238b9248a34cce8b29ba64d5f239df
,這裏是響應我回去(不要被200所欺騙):
Status: 200 OK
<?xml version="1.0" ?>
<image_process_response>
<status>SecurityError</status>
<err_code>614</err_code>
<description>Error in POST parameters: one or more parameters (DATA , SIGN_DATA or APP_ID) are empty</description>
</image_process_response>
下面是我用來創建SHA1的PHP代碼:SIGN_DATA
:
<?php
echo hash_hmac('SHA1', '<image_process_call><lang>en</lang><image_url order="1">http://www.w3schools.com/html/pic_mountain.jpg</image_url><methods_list><method order="1"><name>desaturation</name></method><method order="2"><name>cartoon</name><params>fill_solid_color=1;target_color=(255,255,255);border_strength=20;border_width=3</params></method></methods_list><result_format>png</result_format><result_size>600</result_size></image_process_call>','<my-key>');
?>
這裏是從上面的xml,格式化爲可讀性:
<image_process_call>
<lang>en</lang>
<image_url order="1">http://www.w3schools.com/html/pic_mountain.jpg</image_url>
<methods_list>
<method order="1">
<name>desaturation</name>
</method>
<method order="2">
<name>cartoon</name>
<params>fill_solid_color=1;target_color=(255,255,255);border_strength=20;border_width=3</params>
</method>
</methods_list>
<result_format>png</result_format>
<result_size>600</result_size>
</image_process_call>
任何幫助,將不勝感激。提前致謝!
您不應該同時發送'DATA'和'SIGN_DATA'嗎?由於'hmac'返回一個散列,從哪個API不能恢復你傳遞的原始xml內容。 –
@u_mulder我試圖與有效載荷的其餘部分一起發送上行數據,現在我得到這個錯誤: '的SecurityError 無效SIGN_DATA參數描述>' –
youravgjoe
@u_mulder那修復了部分問題。我還刪除了' en ',現在API已經過了。謝謝您的幫助! –
youravgjoe