2

I have this API

mywebsite.com/v1/api/Endorsements/xxxxxx/User/5003C2D5-6FD6-49BA-A309-EBB81A89FB60/RequestType/All/PageNo/1/PageSize/6/Object/null/Category/null/Search/null/Latitude/null/Longitude/null/Radius/null/StartDate/null/EndDate/null?Auth-Token=A682CCB8-C5D6-47C3-BDF5-8EEC00A164ABapi.salamplanet.com/v1/api/Endorsements/81158/User/5003C2D5-6FD6-49BA-A309-EBB81A89FB60/RequestType/All/PageNo/1/PageSize/6/Object/null/Category/null/Search/null/Latitude/null/Longitude/null/Radius/null/StartDate/null/EndDate/null

and Auth-Token = "XXXXXXXXXX"

I want to get JSON from this API using PHP.

Note: I am new in PHP please help.

2
  • 1
    $json = json_decode(file_get_contents("http://your_url"), true); ? Commented Aug 7, 2016 at 6:54
  • 1
    All that has been posted is a program description. However, we need you to ask a question. We can't be sure what you want from us. Please edit your post to include a valid question that we can answer. Reminder: make sure you know what is on-topic here, as asking us to write the program for you and suggestions are off-topic. Commented Aug 7, 2016 at 7:01

2 Answers 2

4

Use json_decode to convert json data to array.

$url='http://your_url';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'rohit');
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
$resultArray = json_decode($result);
echo "<pre>";
print_r($resultArray);
Sign up to request clarification or add additional context in comments.

Comments

4

This can also be done as..

$url='http://your_url';
$result = file_get_contents($url);
$resultData = json_decode($result);
echo "<pre>";
print_r($resultData);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.