Szerző Téma: Libcurlemu 500 error  (Megtekintve 663 alkalommal)

Libcurlemu 500 error
« Dátum: 2017. szeptember 11. - 20:41:55 »
0 Show voters
Sziasztok! Hiába raktam be a libcurlemu-t (mivel ezen a szerveren NEM tudom máshogy felrakni) erre a kódra 500 error-t kapok
 

<?php

require_once(\'libcurlemu.inc.php\');
 
$title = \'valami - Teszt\';
    $message = \'Valaki tett valamit és neked ezt tudnod kell!\';
    $url = \'http://*censored*\'
    $apiToken = \'*api key*\';
    $curlUrl = \'https://pushcrew.com/api/v1/send/all\';
   
    //set POST variables
    $fields = array(
      \'title\' => $title,
      \'message\' => $message,
      \'url\' => $url
    );
    $httpHeadersArray = Array();
    $httpHeadersArray[] = \'Authorization: key=\'.$apiToken;
    //open connection
    $ch = curl_init();
    //set the url, number of POST vars, POST data
    curl_setopt($ch, CURLOPT_URL, $curlUrl);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeadersArray);
    //execute post
    $result = curl_exec($ch);
    $resultArray = json_decode($result, true);
    if($resultArray[\'status\'] == \'success\') {
        //success
        echo $resultArray[\'request_id\']; //ID of Notification Request
    }
    else if($resultArray[\'status\'] == \'failure\') {
        //failure
        echo \'failure\';
    }
    else {
        //failure
        echo \'failure\';
    }
 
?>

 
De amit kaptam hozzá example.php, abban tökéletesen működik.
 

<?php
// CURL Extension Emulation Library Example
//
// Usage should be straightforward; you simply use this script exactly as you
// would normally use the PHP CURL extension functions.
// first, include libcurlemu.inc.php
require_once(\'libcurlemu.inc.php\');
// at this point, libcurlemu has detected the best available CURL solution
// (either the CURL extension, if available, or the CURL commandline binary,
// if available, or as a last resort, HTTPRetriever, our native-PHP HTTP
// client implementation) and has implemented the curl_* functions if
// necessary, so you can use CURL normally and safely assume that all CURL
// functions are available.
// the rest of this example code is copied straight from the PHP manual\'s
// reference for the curl_init() function, and will work fine with libcurlemu
// create a new CURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, \"http://www.example.com/\");
curl_setopt($ch, CURLOPT_HEADER, false);
// grab URL and pass it to the browser
curl_exec($ch);
// close CURL resource, and free up system resources
curl_close($ch);
 
?>

 
 
« Utoljára szerkesztve: 2017. szeptember 11. - 20:42:38 írta thegergo02 »

Libcurlemu 500 error
« Válasz #1 Dátum: 2017. szeptember 12. - 16:13:18 »
0 Show voters
BUMP

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal