Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

osahsh's avatar

301 moved permanently

why i get this message when i deal with this api https://apidocs.tokeet.com/ i deal with Tasks module . this is my code in laravel

public function test1(){

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "http://capi.tokeet.com/v1/task?account=my-id/",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Authorization: my-token"
    ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
//dd($response);
curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}

}

i get this response

301 Moved Permanently nginx/1.12.0

0 likes
4 replies
cmdobueno's avatar
Level 18

Not to sounds like a jerk, but honestly... it tells you exactly... the end point has moved permanently. Id advise looking over their api documentation or allow redirects within curl. EG: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

osahsh's avatar

now i get another problem which is the response becomes like :

{ "error" : { "code" : 400, "message" : "Your request body is not valid JSON." } }

this is the new code

$data=array( 'name' => 'osama shaheen', 'due' => '500000', 'list' => 'none', ); $data=json_encode($data); //dd($data); $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => "http://capi.tokeet.com/v1/task?account={{1499700995.4461}}",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_SSL_VERIFYPEER  => false,
        CURLOPT_POSTFIELDS  => array('payload' => $data),//"{  \"name\": \"My Test Task\",\n  \"list\": \"Some list\",\n  \"due\": 12312124124124\n}",
        CURLOPT_HTTPHEADER => array(
            "Authorization: {{0aad3f53-e918-4ea5-b1fc-08a72670bc9e}}"
        ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
        echo "cURL Error #:" . $err;
    } else {
        echo $response;
    }

Please or to participate in this conversation.