imgur api에 대한 질문이 있습니다. imgur API를 사용하여 내 웹 사이트 용 갤러리를 만들고 싶지만 imgur 서버에 업로드하는 파일 업 로더를 만들려면 어떻게해야합니까? 여기imgur api가 작동하지 않습니다.
내가 만든 것입니다 :
<?php
include 'xmlparser.php'; // From http://www.criticaldevelopment.net/xml/doc.php
if($_SERVER['REQUEST_METHOD'] == "POST"){
$data = file_get_contents($_FILES["file"]['tmp_name']);
// $data is file data
$pvars = array('image' => base64_encode($data), 'key' => HERE_MY_API_KEY);
$timeout = 30;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://api.imgur.com/2/upload.xml');
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);
$xml = curl_exec($curl);
$parser = new XMLParser($xml);
$parser->Parse();
echo $parser->images->item->links->original;
curl_close ($curl);
}
else
{
?>
<form action="test.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
}
?>
는하지만이 작동하지 않는 것 ...? 내가이 오류 :
구문 분석 오류 : 구문 오류, 예기치 못한 T_STRING, 예상 ')'C에서 : 7 호선
그리고 7 호선에 \ 데이터 \ 홈 \ www가 \의 test.php이 행은 다음과 같습니다
$pvars = array('image' => base64_encode($data), 'key' => HERE_MY_API_KEY);
무엇이 잘못 되었나요? imgur API의 문서는 다음과 같습니다. http://api.imgur.com/examples
저를 도와 줄 수 있습니까? 이러한 주제를 통해
그리고 그래, 난 이미 검색 :
HTML Upload Form will only upload files found in the directory of the PHP file
Using jQuery to parse XML returned from PHP script (imgur.com API)
그러나 그것은 나를 도움이되지 않았다 ...
인사말
에 대한 내 머리 떨어져 당신이 따옴표에 API 키를 가하고 있습니다 빼서? –
@Daniel : 아니요, 설명서에 내가 그렇게해서는 안된다고 ... – Thew
설명서에서 어디에서 말하는가? –