아래와 같이 코드 작성했구요.
$access_token은 로그인할 때 받은거 회원정보에 저장하고 있다가 아래 API CALL이 있을 때 가져오는 방식입니다.
그런데 400에러가 뜨네요. 무슨 문제 일까요? $access_token이 오래되어서 그럴까봐 갱신까지 했는데 그러네요.
$url = "https://kapi.kakao.com/v1/api/story/linkinfo?url=".$surl;
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: Bearer $access_token\r\n"
)
);
$context = stream_context_create($opts);
$data = file_get_contents($url, false, $context);
$url = "https://kapi.kakao.com/v1/api/story/post/link";
$opts = array(
'http'=>array(
'method'=>"POST",
'header'=>"Authorization: Bearer $access_token\r\n",
'content'=>"link_info=".$data."&content=".$msg
)
);
$context = stream_context_create($opts);
file_get_contents($url, false, $context);