CURL Help

Discussion in 'PHP' started by mrphp, Aug 31, 2012.

  1. #1
    Hi,

    I was wondering how to code this request in PHP

    curl --request GET \
    --user-agent "Your Client Name/1.0" \
    --header "Authorization: Basic YWRtaW46WW91ckFQSUtleUhlcmU=" \
    https://www.example.com/api/v2/products

    Any help is highly appreciated.

    Kind regards
     
    mrphp, Aug 31, 2012 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Use the following setopt options:

    user-agent -> CURLOPT_USERAGENT
    header -> CURLOPT_HTTPHEADER

    There is a good example in the comments section (in the above setopt link) on how to add Authorization: Basic option to headers.
     
    ThePHPMaster, Aug 31, 2012 IP
  3. elitestar47

    elitestar47 Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Agreed to ThePHPMaster, You should use this.
     
    elitestar47, Sep 1, 2012 IP