I am suddenly getting a new error back from the API.

Fatal error:  Uncaught my.birthdate attribute of result is not a valid ISO-8601 date: null (500)
 thrown in /home/foo/public_html/blognet/ningapi/NingApi.php  on line 208

I have been running this identical script via a Cron job for quite a while, but did recently change hosts. The error does not seem host related, though. I have not customized NingApi.php at all.

It appears that as I pull back member data, it is hitting a record that has a birthday issue, perhaps? It is returning some member data, until it hits this snag.

 

$count = 30;
$fields    = "id,fullName,profileQuestions,email";
$path    = sprintf("User/alpha?count=%s&fields=%s&isMember=true&anchor=%s", $count, $fields, $anchor);
$result    = $ningApi->get($path);
$anchor = $result[anchor];

 

Any ideas?

Views: 76

Reply to This

Replies to This Discussion

Hi Marc,

 

The engineering team is investigating this issue, I'll update this thread when a fix is deployed.

 

Devin -- any progress on this?  Would like to restore the API soon.

 

Marc

Hi Marc,

 

This fix has been deployed. Let me know if you still see this issue.

I'm no longer seeing the birthdate error but I'm now having some other issue. We have several hundred members but the loop I'm using seems to die after pulling back only 30. See the code I'm using above, which has worked fine in the past. As a test I echoed the path and anchor, which you can see only makes it thru 1 loop and appears to die after the first anchor is part of the query:

 

PATH: User/alpha?count=30&fields=id,fullName,profileQuestions,email&isMember=true&anchor=

ANCHOR: Y7cPIlBowXZJgRaI1LVNexQCe9VC0s92

 

PATH: User/alpha?count=30&fields=id,fullName,profileQuestions,email&isMember=true&anchor=Y7cPIlBowXZJgRaI1LVNexQCe9VC0s92

ANCHOR: Y7cPIlBowXa6FR4y_xyZAzdjhVLT8ZCL

Marc,

 

Can you send me the error that you are receiving? Please include trace so I can look it up in our logs.

 

Devin -- I don't think there is actually an error. What appears to be happening is that the full loop just appears to die before it's finished. Interestingly, on one test it made it thru Anthony Maeding and on another it made it thru Bob Sixta. So that tells me it relates to either

1) the earlier issue I reported on where the API appears to get overtaxed. You asked me to set the count down to 30, which worked for a while. Now 30 may be too many, OR

 

2) the script is timing out

 

I can set it down further and test, but with thousands of members, the script is taking really long to complete.

 

To refresh your memory, I'm only needing to pull back a small group of members who have entered data in a target profile question. Of the thousands of members, we're taking about under 100.

 

You mentioned hoping to add the ability to target profile Qs in the API, and I'm wondering if that is in the near future. In the absence of that, do you have any other suggestions to accomplish this?

 

Thanks!

 

Marc

I heard back from the host:
Your script was getting killed by our firewall software, which has been configured to kill off scripts launched from user shells, cron jobs etc that exceed a certain memory threshold. Your scripts were consuming about 150+ MB at which point our software killed them off. I would suggest tweaking the script if possible so that it consumes less memory.

So my approach of using your API to crawl our member list is not working, at least as currently implemented. The script below is exceeding 150MB well before it even gets thru 100 members in some runs, and even when I've removed all of my additional code inside the loop.


    do {
      
        set_time_limit(180);
        $count = 30;
        $fields    = "id,fullName,profileQuestions,email";
        $path    = sprintf("User/alpha?count=%s&fields=%s&isMember=true&anchor=%s", $count, $fields, $anchor);
        $result    = $ningApi->get($path);
        $anchor = $result[anchor];
      
        echo "PATH: $path\rANCHOR: $anchor\r";

    } while ($result[entry]);
   
 Is there another approach I can use to achieve  what I'm looking for? I'm just trying to query our members and pull back the answer to question 28 for anyone who has completed it. Can I do this at the point when a member enters or updates this field?

 

Any recommendations?

Hi Marc,

 

If you're web host is limiting your scripts I recommend running the script on your local machine from the command line.

 

Another option is to remove the loop and only make one request per run of your script and output the anchor at the end of the script. The anchor that you produce on the first run can serve as the input for the second run.

 

If you don't mind clarifying your suggestions a little more, I will pass along to the client.

 

1. Local Script

Running the script locally & using a remote DB connection to send the data to the host db. Is that what you mean?

 

2. Remove loop

Were I to run the script once every 15 minutes, capturing 30 members each time, that would only allow me to query 2880 members in a 24 hour period. I can see that being insufficient shortly. To clarify, can I assume that when the last member is reached, no anchor would be returned and the next query would essentially return to the first 30 members?

 

3. Does it really consume 150MB of memory to pull back a hundred names via your API? Just wasn't sure if that pointed to some other issue. It seems high.

 

4. Is there any alternative way to target just the group I'm interested in? Are profile-specific API queries on the horizon?

 

Thanks

1. Local Script

I did not realize you required a connection to a local database. You probably don't want to run it locally if that's the case.

2. Remove loop

You shouldn't need to wait that long between running your script. Once the script ends it will release all of it's memory to bet used by the next run. I would run one right after each other.

When you reach the end the 'lastPage' property will be set to true. Use that property to determine when you have reached the end.

3. Memory requirements

I've never profiled the PHP client code, so I'm not sure what the expected memory requirements are. I haven't run it on a server with the requirements that you have.

4. Alternatives

There is nothing planned yet but I keep asking.

Our host only allows a CRON script to run every fifteen minutes.

Would this be how lastPage is returned?

$result = $ningApi->get($path);
$lastPage = $result[lastPage];

If you can only run a script every 15 minutes, your host may not be ideal for long running scripts.

 

Correct, that is how you would access the lastPage property.

 

Reply to Discussion

RSS

Blog Posts

Getting Started

Posted by Kyle Ford on October 13, 2010 at 8:00am 3 Comments

A Note on API Pricing

Posted by Phil McCluskey on October 1, 2010 at 8:55am 0 Comments

Welcome to Build!

Posted by Kyle Ford on September 30, 2010 at 8:30pm 1 Comment

Ning Status

© 2024   Created by Build Team.   Powered by

Badges  |  Report an Issue  |  Terms of Service