/    Sign up×
Community /Pin to ProfileBookmark

Send Post Request to JSON API Using PHP CURL

Hello people,
It’s my first post here. Can you help show me how I can send post request to this API body below with raw PHP? I’m only having a challenge in the “questions” sub-array. There, fetching questions from database using a while loop and sending those data in that sub-array. I’m able to send data to other part of the API body.
`{
“id”:”1222″,
“quizName”:”Mid Term quiz”,
“numberOfQuestions”:”1″,
“isTimed”:false,
“numberOfMinutesToComplete”:”30″,
“targetedClass”: “Js 3”,
“subject”:”Basic Studies”,
“schoolLevel”:”Secondary School”,
“questions”:[
{
“question”:”What is Algebra”,
“questionMark”:”10″,
“options”:[
{
“option”:”A”,
“answer”:”is Good”
},
{
“option”:”B”,
“answer”:”God is good”
},
{
“option”:”C”,
“answer”:”Nigeria is My Country”
}
],
“hasImage”:true,
“images”:[
“images-1”,
“images-2”
],
“correctionOption”:”A”
},
{
“question”:”When Did Nigeria gain here independence”,
“questionMark”:”10″,
“options”:[
{
“option”:”A”,
“answer”:”2000″
},
{
“option”:”B”,
“answer”:”1980″
},
{
“option”:”C”,
“answer”:”1960″
}
],
“hasImage”:true,
“images”:[
“images-1”,
“images-2”
],
“correctionOption”:”A”
},
{
“question”:”Who Designed the nigeria flag”,
“questionMark”:”10″,
“options”:[
{
“option”:”A”,
“answer”:”Charles Onuorah”
},
{
“option”:”B”,
“answer”:”Godluck Jonathan”
},
{
“option”:”C”,
“answer”:”I don’t know”
}
],
“hasImage”:true,
“images”:[
“images-1”,
“images-2”
],
“correctionOption”:”C”
}
],
“totalValidMarks”:”10″,
“validUntil”:”2020-08-10″
}`

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @joseph67 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...