Curl gibt true zurück, statt Wert

Ich versuche eine einfache API. Jedoch, nicht sicher, warum, aber ich bin immer true anstatt des Wertes, der zurückgegeben werden soll.

Hier ist die curl-code.

try
        {
        $target_url = "my url";
        $post = array(
            'auth_token' => '123456' //post your auth token here
            //'file_contents' => '@' . $_FILES['file']['temp_name']); //the name of the input type is file, you can change it in your HTML.
            );
        $ch = curl_init();
        if($ch == false)
        {
            echo "Couldnt initialize curl";
        }
        curl_setopt($ch, CURLOPT_URL,$target_url);
        curl_setopt($ch, CURLOPT_POST,1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        $result=curl_exec ($ch);
        if (FALSE === $result)
            throw new Exception(curl_error($ch), curl_errno($ch));
        var_dump($result);
        curl_close ($ch);
        }
        catch(Exception $e)
        {
            trigger_error(sprintf(
        'Curl failed with error #%d: %s',
        $e->getCode(), $e->getMessage()),
        E_USER_ERROR);
        }

Die Datei wird dem Inhalt :-

return $_POST['auth_token']

Jedoch das Ergebnis var_dump bool(true) anstelle von 123456.
Warum ist das passiert?

InformationsquelleAutor Rahul Sarkar | 2015-03-11
Schreibe einen Kommentar