Skip to content
TORNLIFE More

PHP multi cURL

Started by Mattchew [361253] on in API Development.

3 replies · 91 views · thread synced · 4 days ago · View on torn.com
About this thread

Posts archived: 4 / 4 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
4
Discussion span
→
People posting
3
Likes on archived posts
4
Authority score
51 / 100
Historical score
19 / 100
Story score
27 / 100
Engagement score
44 / 100
Mattchew [361253]

Hi all,

While not strictly a question about the API directly, I think it's still a handy question to ask. I'm working on a PHP based website to learn web development using Torn's API. If I make something worth sharing, I'm sure I'll be making another post in this forum :)

Anyway, the issue I'm having is that I need to make a few API requests in parallel otherwise the page takes to long to load and times out - I could request sequentially and increase the length of the timeout but I don't particularly want to wait 30+ seconds everytime the page loads.

I know cURL is the answer, I just can't figure out for the life of me how to use it.

Not 100% sure this is where the issue is but I expect it's something to do with: curl_multi_exec() (

I am using the same execution method as the first example on the above link but want to store the results (I assume the JSON provided by the Torn API?) in separate variables so I can work with them later. Pretty sure that loops does not store the contents in the cURL handles? Using: var_dump(curl_multi_getcontent($ch1)) is an empty string: string(0) "". and echoing one of the cURL handles echoes this: resource(1) of type (curl). The number in "resources(x)" is the cURL handle number.

Hopefully, that makes sense! And hopefully someone can point me in the right direction or put me out of misery! It's driving me nuts.

Thanks!


Mattchew [361253]

Personally, I've given up at this cURL path. But as this is a joint adventure I'll give him some time. Maybe he'll conjure something up before I figure out how to use this library.. I most likely will be using this library in no time though. If not a complete redesign! Woo woo!

Thank Mauk!