Authenticating using curl

Viewed 38

I want a curl script to get response from oneup api.

The api link looks like

curl https://api.oneup.com/v1/customers -u "api_12_e3ab@api.oneup.com:34a352e421d03a4qXqc91f9b48ed7eb02e5"

My code is below:

<?php

$url = "https://api.oneup.com/v1/customers -u 'api_133896_9f73@api.oneup.com:70213567295f25ba9fde5127a4348fa22c1b2789'";
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13');
$output = curl_exec($ch);  
curl_close($ch);  
echo $output;
?>

I get the output 1 only

enter image description here

1 Answers
Related