Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8576459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:55:42+00:00 2026-06-11T19:55:42+00:00

So here is the question. I’m trying to call my api with PHP CURL

  • 0

So here is the question. I’m trying to call my api with PHP CURL post like so

<?php
        $ch = curl_init();
        $data = array('page' => $pageid);
        $data = json_encode($data);

        $fields = 'data=' . urlencode($data);

        /*echo $fields; ## data=%7B%22page%22%3A%222%22%7D */

        curl_setopt($ch, CURLOPT_URL, 'http://www.myurl.com/api/gallery');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        $result =curl_exec($ch);

        $products=json_decode($result,true);
?>

and In my API which is using zend framework, I received the data like so

<?php
        $data = json_decode($this->_getParam('data',''), true);
        $query = array();
        $query['status'] = '1';
        $query['pid']   = (isset($data['pid']))? $data['pid'] : '';
        $query['search'] = (isset($data['search']))? $data['search'] : '';
        $query['orderby'] = (isset($data['sort']))? $data['sort'] : 'latest';
        $query['page'] = (isset($data['page']))? $data['page'] : '1';
        $query['pagelimit'] = (isset($data['pagelimit']))? $data['pagelimit'] : '2';
?>

when I check the value in query, it didn’t received the “page” value passed by using CURL.. Am I doing something wrong?

Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:55:43+00:00Added an answer on June 11, 2026 at 7:55 pm

    At first, you should check _getParam method that returns POST variables correctly.

    Then, Note, you should use json_decode on one really json string! you should decode url data variable(result of $this->_getParam(‘data’,”)) and then pass it to json_decode!

    I assume your _getParam method works correctly,
    then:

    $data = json_decode(urldecode($this->_getParam('data','')), true);
    $query = array();
    .
    .
    .
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basic question here - I have many lines of code that look something like:
Simple question here: I like to know if a constraint in a oracle database
Simple question here: is there any way to convert from a jagged array to
The question here is whether something like this already exists or, if not, whether
first question here, be nice :P I am trying to make an infinite UIScrollView
Quick question here about short-circuiting statements in C#. With an if statement like this:
stupid question here. I'm trying to create a helper method, something similar to the
First question here. I am trying to instantiate a generic class using the type
Jquery question here. I would like to get the CLASS tag of the only
First question here. I'm trying Javascript objects. Here's my code: function main(){ document.onkeydown =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.