我想调用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