Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Akinyele Olubodun
    @akinyeleolubodun
    Multiple header entry is not working
    Nick Sagona
    @nicksagona
    ok do you have a code example?
    Akinyele Olubodun
    @akinyeleolubodun
    Yes I do
    let me get it
    Nick Sagona
    @nicksagona
    k
    Akinyele Olubodun
    @akinyeleolubodun
    $curl = new Curl($api_details->url, [CURLOPT_HTTPHEADER => Array
    (
    mp-master-key:cd391579-8347-e019144dcf0f,mp-private-key:live_private_fOqn7hRfjY1uY,mp-token:623aae45
    )]);
    $curl->setPost(true);
    $curl->setFields($data);
    Nick Sagona
    @nicksagona
    wait - the Http Curl class?
    or the pop mail?
    Akinyele Olubodun
    @akinyeleolubodun
    Yes
    Sorry...not mail
    Mail works fine
    Nick Sagona
    @nicksagona
    ok
    Akinyele Olubodun
    @akinyeleolubodun
    The company sent me a script that works
    I realised the header was not being set
    Nick Sagona
    @nicksagona
    i don't think you can set multiple HTTPHEADERS with curl option
    Akinyele Olubodun
    @akinyeleolubodun
    Hummm
    Nick Sagona
    @nicksagona
    maybe you can with one call
    Akinyele Olubodun
    @akinyeleolubodun
    Let me show you the script that works
    Nick Sagona
    @nicksagona
    but I definitely think your issue lies with curl underneath and not the pop component
    b/c the Pop\Http\Client\Curl object just passes the option/value pair onto the curl_setopt function
    Akinyele Olubodun
    @akinyeleolubodun
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://url/charge",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_SSL_VERIFYHOST =>0,
        CURLOPT_SSL_VERIFYPEER=>0,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => json_encode(
              array(
                  "amount"=>"3000",
                  "customer_phone"=>"08068xxxx417",
                  "customer_name"=>"Akinssssss",
                  "customer_email"=>"",
                  "wallet_provider"=>"MTN",
                  "merchant_name"=>"test"
                  )),
      CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache",
        "content-type: application/json",
        "MP-Master-Key: cd3910f",
        "MP-Private-Key: live_priunqazGY",
        "MP-Token: 6fffb23b6a4f123aae45",
      ),
    ));
    Nick Sagona
    @nicksagona
    yea you need to use setOptions() from Pop\Http\Client\Curl
    so that it invokes the curl_setopt_array function
    Akinyele Olubodun
    @akinyeleolubodun
    I think I did, let me try that now and get back
    Nick Sagona
    @nicksagona
    wait
    the parameter in the constructor gets passed to setOptions() anyway
    which in turn gets passed to curl_setopt_array()
    Akinyele Olubodun
    @akinyeleolubodun
    Exactly
    I have been debugging for many hours now
    Nick Sagona
    @nicksagona
    ok your header formatting looks a little off too
    there's no space after the colon and the capitalization isn't the same as the script that works... could be that maybe?
    and you don't have quote around your values
    ?
    Akinyele Olubodun
    @akinyeleolubodun
    I have tried everything
    Nick Sagona
    @nicksagona
    mp-master-key:cd391579-8347-e019144dcf0f,mp-private-key:live_private_fOqn7hRfjY1uY,mp-token:623aae45
    Akinyele Olubodun
    @akinyeleolubodun
    Hummm maybe that matters
    Let me change it and get back now
    Nick Sagona
    @nicksagona
    have you tried exactly like them?
    I would you'd have to do it exactly like them:
    CURLOPT_HTTPHEADER => array(
    "MP-Master-Key: cd391579-8347-e019144dcf0f",
    "MP-Private-Key: live_private_fOqn7hRfjY1uY",
    "MP-Token: 623aae45"
    )
    quotes, capitalization, spaces and commas just like that
    Akinyele Olubodun
    @akinyeleolubodun
    That is what I am trying to do now
    Akinyele Olubodun
    @akinyeleolubodun
    Getting the same error
    $curl = new Curl($api_details->url, [CURLOPT_HTTPHEADER => ["mp-master-key: cd3919144dcf0f", "mp-private-key: live_pRfjY1unqazGY", "mp-token: 623aae45"]]);
    Nick Sagona
    @nicksagona
    What's the error?
    Akinyele Olubodun
    @akinyeleolubodun
    I was meant to get "{"response_code":"1001","response_text":"Logon to your MPower account and set your integration mode to live"}"
    But I have been getting "{"response_code":"2001","response_text":"Exception, An Error Occured on the server."}"
    Nick Sagona
    @nicksagona
    are you checking the response in the curl object? looking inside there at the return headers and body and all?
    b/c it really seems like the issue is with the headers and the communication with the server (and not the pop curl object)
    Akinyele Olubodun
    @akinyeleolubodun
    This is how I am getting the response print_r($curl->getBody());