두 시스템 간의 연결을 만들려고하는데 그 중 하나가 main입니다. 연결은 cURL을 통해 제공됩니다. 유효한 액세스를 요청 보낸 사람의 & 비밀 키를 제공하여 인증을 받아야합니다 API 휴식을PHP에서 REST API를 사용하는 cURL
각 요청 : 만 2insctructions을 가지고, 내가 연결을 시도하고있는 시스템에서
private function build_post($url, $params, $authentificate = true) {
//url-ify the data for the POST
$params_string= http_build_query($params);
$curl = curl_init($url);
//set the url, number of POST vars, POST data
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl,CURLOPT_POST, count($params));
curl_setopt($curl,CURLOPT_POSTFIELDS, $params_string);
if ($authentificate) {
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'x-api-key: key1',
'x-api-skey: key2'
));
}
//execute post
$curl_response = curl_exec($curl);
if ($curl_response === false) {
$info = curl_getinfo($curl);
curl_close($curl);
echo('error occured during curl exec. Additioanl info: '.var_export($info));
}
else
{
echo 'Responze OK';
curl_close($curl);
}
}
:이 기능이 머리글. 예
:
X-API 키 :
X-API-SKEY D6d03y3h0iEW7Iz3xW9127a0xrh1ib : sc1vcOTTFLuqjFa5u08UKtKaWl48XSqlm8jMQvrnXnuPvRjqTPgIDI6P1YcR
및 제 2 명령을 수행해야 같은 기둥 모양을 요청하는 방법이다.
나는 아무 생각, 왜 내가이 얻을 모든 시간을 무엇을하려고하지 않은 :array ('url' => 'https://rest.api.profitee.com/public/subscribe', 'content_type' => NULL, 'http_code' => 0, 'header_size' => 0, 'request_size' => 0, 'filetime' => -1, 'ssl_verify_result' => 1, 'redirect_count' => 0, 'total_time' => 0.037060000000000002662314813051125383935868740081787109375, 'namelookup_time' => 0.0003939999999999999817472395857720357525977306067943572998046875, 'connect_time' => 0.037070999999999999785504911642419756390154361724853515625, 'pretransfer_time' => 0, 'size_upload' => 0, 'size_download' => 0, 'speed_download' => 0, 'speed_upload' => 0, 'download_content_length' => -1, 'upload_content_length' => -1, 'starttransfer_time' => 0, 'redirect_time' => 0, 'certinfo' => array (), 'primary_ip' => '54.229.78.229', 'redirect_url' => '',)error occured during curl exec. Additioanl info: NULL
누군가가 나에게 그것이 작동되도록 도와 드릴까요? 감사합니다
오류가 있습니까? –
아니,이 배열은 ... –
"curl exec 중에 오류가 발생했습니다"라는 오류 메시지가 나타납니다 Additioanl info : NULL ", curl_error ($ curl_response); 이 더 많은 정보를 제공 할 수 있습니다 –