Keep getting warning error: Invalid argument supplied for foreach()

PaigeB0
Participant

Keep getting warning error: Invalid argument supplied for foreach()

For the sample API forms, are there entries that need to be made that aren't covered in the instructions? I keep getting the following error on forms in different lines on form pages: Warning: Invalid argument supplied for foreach()

13 REPLIES 13
Ryan_D
Employee

Hey Paige,

 

This issue was brought to my attention today and should be fixed as of now.  Please download again from our repository and the foreach warning should go away.

Ryan Davis
Quality Engineer
g00
Occasional Participant

I just downloaded the sample forms for php and I'm getting the same error. Any suggestions?

Hey,

 

Did your download have the V2.zip or was it the original?  I just made an update to the file which does not report the warning back to me on my live or sandbox environment.

Ryan Davis
Quality Engineer
g00
Occasional Participant

The file name is PHP_Contact_For_msV2.zip.  

Which part of the sample forms are you seeing this error? 

Ryan Davis
Quality Engineer

Was there any solution provided for this yet? - I am getting the same error - see below:

 

PHP Notice: Trying to get property of non-object in D:\wwwroot\e-conoair.com\www\SampleForms\cc_class.php on line 167 PHP Warning: Invalid argument supplied for foreach() in D:\wwwroot\e-conoair.com\www\SampleForms\cc_class.php on line 167

 

Here is the code it is referencing:

 

 foreach ($parsedReturn->link as $item) {
                $tmp = $item->Attributes();
                $nextUrl = '';     
                if ((string) $tmp->rel == 'next') {
                    $nextUrl = (string) $tmp->href;
                    $arrTmp = explode($this->login, $nextUrl);
                    $nextUrl = $arrTmp[1];
                    $call2 = $this->apiPath.$nextUrl;
                    break;
                  }

 

I also get the same error on the next foreach statement:

 

 foreach ($parsedReturn->entry as $item) {
                if ($this->contact_lists ){
                if (in_array((string) $item->title, $this->contact_lists)) {
                    $tmp = array();
                    $tmp['id'] = (string) $item->id;
                    $tmp['title'] = (string) $item->title;
                    $mailLists[] = $tmp;
                   }

Hey Raul,

 

I just released a new version of the sample forms about two days ago.  Which version are you using and what are you doing with in the sample forms to get this warning.

 

 

Ryan Davis
Quality Engineer
JohnC2028
Regular Participant

Hello,

 

I am getting this error:

 

Warning: Invalid argument supplied for foreach() in /home/mdutler/public_html/wp-content/themes/whiteboard/constantcontact/cc_class.php on line 167

Warning: Invalid argument supplied for foreach() in /home/mdutler/public_html/wp-content/themes/whiteboard/constantcontact/cc_class.php on line 179

 

On this web page:

 

http://thebatterzbox.com/

 

You can see the error.

 

I just updated the plugin from within WP and the versions are attached.

 

May I please get some assistance in getting this resolved?


woo.jpg
JohnC2028
Regular Participant

Has any seen this? Maybe have a resolution?

Hi John,

 

Sorry, but plugins are supported by the companies that wrote the code for them. I'd recommend contacting the plugin developer "Visit Plugin Site" from the screenshot and asking them about the error. If they think that our API is the issue, we just need them to contact us at webservices@constantcontact.com with the payload they're sending over and the URL they're trying to hit on our side. From the error though, their script isn't making any request to us (it's not getting that far). We may still be able to help if they can provide more information about their code or when the error occurs (what happens around lines 167 or 178). Thanks!

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

JohnC2028
Regular Participant

so you re saying this line isnt your product?

 

Warning: Invalid argument supplied for foreach() in /home/mdutler/public_html/wp-content/themes/whiteboard/constantcontact/cc_class.php on line 179

Hi,

 

Correct; it's included as part of a plugin developed outside of Constant Contact, though it does contain code intended to use our API's to do something within accounts.

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

JohnC2028
Regular Participant

Thank you for your help!!

 

Developer Portal

View API documentation, code samples, get your API key.

Visit Page