我有下面的curl代码来检查一个数字是否已激活。但我不知道怎么用这个。如何在php中实现这一点以获得json输出。
卷曲码:
curl --get --include "https://dndcheck.p.mashape.com/index.php?mobilenos=9999999999%2C8888888888" \
-H "X-Mashape-Key: g5Svg3wHuomshHIyjncC0hetIUVXp1h7E0LjsnJmorZlVxUcQV"指向api和文档的链接:https://www.mashape.com/blaazetech/dnd-check
发布于 2014-10-24 05:16:14
试试这个,告诉我它是如何为你工作的:
<?php
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"X-Mashape-Key: g5Svg3wHuomshHIyjncC0hetIUVXp1h7E0LjsnJmorZlVxUcQV"
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$res = file_get_contents('https://dndcheck.p.mashape.com/index.php?mobilenos=9999999999%2C8888888888', false, $context);
print_r(json_decode($res, true));
?>希望这足以让你开始工作。
在实践中,我猜你将不得不使钥匙和电话号码获得一个变量,但这是微不足道的。
https://stackoverflow.com/questions/26539718
复制相似问题