Jump to content

trying to get $postdata and curl to get members.txt data


Viago

Recommended Posts

ok i have been trying for over a week now, and i just relearning php again after a few years of being lazy. lol

 

here is a code snippet.

//prep the members

$myFile2 = "members.txt";

$fh2 = fopen($myFile2, 'r');

$theData2 = fread($fh2, filesize($myFile2));

fclose($fh2);

//echo $theData2;

//grab the stats!

$url = 'http://link';

$postdata = 'players='.$theData2.'&fields=all';

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);

$data = curl_exec($ch);

curl_close($ch);

$data = json_decode($data,true);

 

the orininal code

//prep the members

$members = "member,member1,member two,member blue";

//grab the stats!

$url = 'http://link';

$postdata = 'players='.$members.'&fields=all';

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);

$data = curl_exec($ch);

curl_close($ch);

$data = json_decode($data,true);

 

now the problium i am having is that with the original way, listing the members indevidualy is not the way i would like it, it would be easyer if it was in .txt form so i can add top it easyer. Also i have 300 people to add and the string doesnt seem to like that many people in it.....so i made a txt file, and it all works except that when i load the page it does not display the members stats from the external link. each players stats gets posted on the page and sorted who is ranked highest.

 

echo works for echoing the contents of the file. however thats usless to me as i want the contents of the file to work like the orininal code.

 

sorry if its confusing....

 

basicaly there is data from the link for each player asociated with there name. which is seperated by a , in the code. so each time a , is reached the code repeats its self posting each player till there are no more to post. the string is to short for me or just seems to not work with 300 people. i need it to read the external .txt file or something simular and work in the same mannor.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.