如何使用curl PHP [英] How to use curl php

查看:96
本文介绍了如何使用curl PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常想使用要求卷曲的API。我什么都不知道。因此,我乐于记录自己,但我不了解所有内容。



API的内容如下:



必须为所有请求提供唯一的API密钥,您可以在仪表板中生成这些密钥。 X-API-ID(公用)和X-API-KEY(专用)参数。例如:

  curl -L http://www.coinimp.com/api/v2/哈希
- H'X-API-
ID:7e26bb94aa2ce44e6e16aca6ae6d28c7f0157b5ccd7a82f86bbbe8d835effd71'
-H'X-API-
KEY:5112486af64b2f97bd3742c4153cee32452549491 $



这是我的代码:

  $ curl = curl_init(); 

$ opts = array(


CURLOPT_URL =>'http://www.coinimp.com/api/v2/哈希',
CURLOPT_HEADER =>数组(
'X-API-
ID:0cd6929b8e34e2cc686eb50bef6a909c4898125b5105221fbfe48a43b038d9ff',
'X-API-
KEY:61dbf2d44abdc138b7c691

$ b);

curl_setopt_array($ curl,$ opts);

$ response = json_decode(curl_exec($ curl),true);

print_r($ response);

这是我的结果:

  HTTP / 1.1 301永久移动日期:Sat,16 Feb 2019 20:19:44 GMT传输编码:分块连接:keep-alive Cache-Control:max-age = 3600过期:Sat, 2019年2月16日21:19:44 GMT位置:https://www.coinimp.com/api/v2/reward服务器:cloudflare CF-RAY:4aa2b5fd8a25c83d-AMS 1 

请帮助我吗?

解决方案

CoinImp是绝对混乱我与他们短暂地合作过一个客户项目,很快就不喜欢他们的服务。您收到301响应,表示您所请求的资源不再位于该地址。在响应中,它似乎为您提供了新的端点:



https://www.coinimp.com/api/v2/reward



我会尝试重新格式化针对该端点的请求。否则,这将是CoinImp支持的问题。


I desperately want to use an API that asks curl. I do not know anything at all. So I teter to document myself, but I do not understand everything.

Here is what the API says:

All requests must be provided with unique API keys, which you can generate in dashboard. X-API-ID (public) and X-API-KEY (private) parameters. For example:

curl -L http://www.coinimp.com/api/v2/hashes
    -H 'X-API- 
ID:7e26bb94aa2ce44e6e16aca6ae6d28c7f0157b5ccd7a82f86bbbe8d835effd71'
    -H 'X-API- 
KEY:5112486af64b2f97bd3742c4153cee32452549491480cfd164b336720b82a84d'

Here is my code:

$curl = curl_init();

$opts = array(


CURLOPT_URL => 'http://www.coinimp.com/api/v2/hashes',
CURLOPT_HEADER => array(
        'X-API- 
ID:0cd6929b8e34e2cc686eb50bef6a909c4898125b5105221fbfe48a43b038d9ff',
        'X-API- 
KEY:61dbf2d44abd138bad67c7876dcac0f58b2f08c8bbb91108c7c0984fe7b5f207',
        )


);

curl_setopt_array($curl, $opts);

$response = json_decode(curl_exec($curl), true);

print_r($response);

Here is my result:

 HTTP/1.1 301 Moved Permanently Date: Sat, 16 Feb 2019 20:19:44 GMT Transfer-Encoding: chunked Connection: keep-alive Cache-Control: max-age=3600 Expires: Sat, 16 Feb 2019 21:19:44 GMT Location: https://www.coinimp.com/api/v2/reward Server: cloudflare CF-RAY: 4aa2b5fd8a25c83d-AMS 1 

Please can you help me ?

解决方案

CoinImp is an absolute mess; I worked with them briefly on a client project and quickly came to dislike their service. You're receiving a 301 response, which indicates that the resource you're requesting is no longer at that address. In the response it appears to give you the new endpoint:

https://www.coinimp.com/api/v2/reward

I would try reformatting your request towards that endpoint. Otherwise, this would be a question for CoinImp support.

这篇关于如何使用curl PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆