Register and join over 40,000 other developers!
Recent Topics
-
The Game You Are Waiting For?
WendellHarper - Dec 06 2020 01:21 PM
-
Quora and Reddit Backlinks
WendellHarper - Dec 06 2020 01:14 PM
-
Delete account
pindo - Jul 23 2020 01:33 AM
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

7 replies to this topic
#1
Posted 06 October 2012 - 07:53 PM
Hi, how can you sent arrays via using CURL? I was told this is possible.
However, I never used the CURL to submit many arrays at one time.
How would one do this?
However, I never used the CURL to submit many arrays at one time.
How would one do this?
#2
Posted 07 October 2012 - 12:50 AM
how do you mean send arrays? by passing them to the page you want to get?
I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.
#3
Posted 07 October 2012 - 03:05 AM
You will just need to get familiar with curl_setopt so you can pack your array the same way a form does,
like this :
like this :
curl_setopt($res, CURLOPT_POSTFIELDS, 'animal[]=cat&animal[]=dog')
#4
Posted 07 October 2012 - 07:51 AM
Well, I am selling items. So, I first sent my cilents to paypal. Then paypal after processing the payment. It sends post data to my ipn script. Which then checks the prices and make sure everything is legit. Then I take that post data and put it in a session.
I then have to use my suppliers api. They have an api where it's like
sending commands. something like commands[1] = section[section_name]& commands[1] = item[1]
something like that. The section is just a group of name of commands.
each section have their own purpose. There are sections for orders. section for check if items are in stock... then there is wholesale orders.
Where you can like buy in bulk. Then there are like holiday items that you can searh. The API is pretty big. They do have documentation aka a pdf file.
However, just shows the sections and the command lines. Doesn't go into detail.
So when I verify everything via paypal. I then start the order processing. So I need to take that session value and was told since it's already in an array. So I didn't have to make a new array. Just reassign it to another variable. Which I did and created my own curl function. So I can process orders to my supplier. The supplier just has items then followed after it says type: Array. I never really heavily used CURL. I have looked at the ops and did write some CURL code before but that was to grab weather data.
would like to know how I can without manually creating the post data in a string. How could you just put a variable instead aka an array?
I then have to use my suppliers api. They have an api where it's like
sending commands. something like commands[1] = section[section_name]& commands[1] = item[1]
something like that. The section is just a group of name of commands.
each section have their own purpose. There are sections for orders. section for check if items are in stock... then there is wholesale orders.
Where you can like buy in bulk. Then there are like holiday items that you can searh. The API is pretty big. They do have documentation aka a pdf file.
However, just shows the sections and the command lines. Doesn't go into detail.
So when I verify everything via paypal. I then start the order processing. So I need to take that session value and was told since it's already in an array. So I didn't have to make a new array. Just reassign it to another variable. Which I did and created my own curl function. So I can process orders to my supplier. The supplier just has items then followed after it says type: Array. I never really heavily used CURL. I have looked at the ops and did write some CURL code before but that was to grab weather data.
would like to know how I can without manually creating the post data in a string. How could you just put a variable instead aka an array?
#5
Posted 07 October 2012 - 09:44 AM
I think I solved this but not sure. Here is what I wanted to do.
Lets assume items variable holds an array of items. I didn't put the items names in the array but for example sake. Just pretend I assigned item names in that array.
I want to send that array already populated and created via curl.
Now, I am assuming I need to first use http_build_query() Function to convert the array to a url format or proper format.
I never sent arrays via CURL but with my supplier their API for some commands requires that I use an array type of values sent to the API.
Oh I also forgot to tell you that I am using HTTPS protocol.
So what extra steps would I need to do to talk with an HTTPS connection?
$items = array(); curl_setop ($res, CURLOPT_POSTFIELDS, $items);
Lets assume items variable holds an array of items. I didn't put the items names in the array but for example sake. Just pretend I assigned item names in that array.
I want to send that array already populated and created via curl.
Now, I am assuming I need to first use http_build_query() Function to convert the array to a url format or proper format.
I never sent arrays via CURL but with my supplier their API for some commands requires that I use an array type of values sent to the API.
Oh I also forgot to tell you that I am using HTTPS protocol.
So what extra steps would I need to do to talk with an HTTPS connection?
#6
Posted 08 October 2012 - 05:45 AM
Using curl on https is not an easy easy, but you can work it out like this
It takes some extra work but that is the way to do it.
It takes some extra work but that is the way to do it.
#7
Posted 08 October 2012 - 01:40 PM
Using curl on https is not an easy easy, but you can work it out like this
It takes some extra work but that is the way to do it.
Thanks I did it.
A new issue that I am seeing is that the posted data is getting converted to an html symbol.
for example I have to pass a variable called currency however when you have ¤ it creates a special money symbol and I am not sure if it breaks the whole chain. The suppliers api documentation says this is required since they accept multiple currencies. Yet, don't know if this effects the post?
I assume it does. So, I am clueless on how to make it not be as a special html characters.
Any idea?
Figured this out by playing around with HTML entities function.
#8
Posted 11 October 2012 - 10:25 AM
Ok, here is my problem
I need to use http_build_query to make the array be urlencoded.
however, I have it named as items. So the array will be like something like this:
items[1][name]=cookies&items[1][price]=5.00
etc... that is what I need the url to look like.
the problem is that when using that http_build_query. I get this:
items1[name]=cookies&items1[price]=5.00
notice the 1 has no [] around it. I need to have [] around the 1.
I don't know if http_build_query has a way to count and put the number inside the brackets [].
any ideas?
I need to use http_build_query to make the array be urlencoded.
however, I have it named as items. So the array will be like something like this:
items[1][name]=cookies&items[1][price]=5.00
etc... that is what I need the url to look like.
the problem is that when using that http_build_query. I get this:
items1[name]=cookies&items1[price]=5.00
notice the 1 has no [] around it. I need to have [] around the 1.
I don't know if http_build_query has a way to count and put the number inside the brackets [].
any ideas?
Also tagged with one or more of these keywords: array
Language Forums →
C# →
Counting the integers frequences in an array entered by the userStarted by AndreMarques, 27 Nov 2017 ![]() |
|
![]() |
||
Language Forums →
PHP →
How Come Variable Not Assigned And Php Knows Where To Look For Value ?Started by uniqueideaman, 06 May 2017 ![]() |
|
![]() |
||
Language Forums →
C and C++ →
help me . c++. ArraysStarted by girl2383, 06 Feb 2017 ![]() |
|
![]() |
||
Language Forums →
C and C++ →
Selecting an element on a 2D arrayStarted by LonelyGuySylar, 18 May 2016 ![]() |
|
![]() |
||
Language Forums →
Java →
Include a specific error, task, problem, or question in your titleStarted by rjb7, 15 Apr 2016 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download