안녕하세요 저는 Parse에 대한 쿼리를 수행하려고합니다. com과 올바른 매개 변수를 사용하지만 JSON 응답에서 다음과 같이 수신합니다.{"code":111,"error":"invalid type for key userid, expected *_User, but got string"}
다음은 코드입니다.
$url = 'https://api.parse.com/1/classes/Tasks';
$headers = array(
"Content-Type: application/json",
"X-Parse-Application-Id: " . $appId,
"X-Parse-REST-API-Key: " . $restKey
);
$objectData = '{"userid":"hQsxiherY2", "tasktitle":"my first title", "taskcontent":"my first content"}';
$rest = curl_init();
curl_setopt($rest,CURLOPT_URL,$url);
curl_setopt($rest,CURLOPT_POST,1);
curl_setopt($rest,CURLOPT_POSTFIELDS,$objectData);
curl_setopt($rest,CURLOPT_HTTPHEADER,$headers);
curl_setopt($rest,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($rest);
echo $response;
curl_close($rest);
$ objectData-> userid에 문제가있을 수 있습니다. 내가 제대로 보내지 않았을 수 있습니다. Parse를 사용하는 모든 사람. com과 내 실수가 어디에 있는지 알고 있습니까? 무엇을 보내야합니까?
귀하의 userid
열은 실제로 포인터가 아닌 ID에 대한 문자열 열입니다. 개체를 연결하는 올바른 방법입니다.
포인터를 사용하여 쿼리 할 때 포인터를 올바르게 생성해야합니다.
문자열 ID 대신 클래스에 "hQsxiherY2"
대한 포인터를 선언해야합니다 _User
.
{"__type":"Pointer","className":"_User","objectId":"hQsxiherY2"}
따라서 위의 코드에서 전체 $objectData
는 다음과 같습니다.
$objectData = '{"userid":{"__type":"Pointer","className":"_User","objectId":"hQsxiherY2"}, "tasktitle":"my first title", "taskcontent":"my first content"}';
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다