# Cybozu WP to kintone error

**URL:** <https://forum.kintone.dev/t/cybozu-wp-to-kintone-error/28>\
**Category:** General\
**Created:** [February 17, 2017, 1:49am UTC](https://forum.kintone.dev/t/cybozu-wp-to-kintone-error/28 "2017-02-17T01:49:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [February 17, 2017, 1:49am UTC](https://forum.kintone.dev/t/cybozu-wp-to-kintone-error/28/1 "2017-02-17T01:49:03Z")

</div>

Hello.

I have installed WordPress plugin “Cybozu WP to kintone” on my WordPress site and get the error message when published.

I &nbsp;used Product Survey app from kintone&nbsp;marketplace as the test case but I get the following error.

**Warning** : Invalid argument supplied for foreach() in&nbsp; **/home/fujibiz/public\_html/wp-content/plugins/cybozu-wp-to-kintone/includes/class-kintone-api.php** &nbsp;on line&nbsp; **218**

![](https://developer.kintone.io/hc/user_images/QAtuROKtBDBI3tBjCWKxlg.png)

This same plugin works on Japanese account.

Any idea to fix this?

&nbsp;The following is the screenshot to show where the error occurred.

![](https://developer.kintone.io/hc/user_images/kZVzywJa5GAzbpBS0VpLag.png)

&nbsp;

/\*  
\* Exclude controls  
\* @param string $control controls  
\* @param string $exclude code name for exclude  
\* @return array $controls  
\* @since 0.1  
\*/  
public static function exclude\_controls( $controls, $exclude = null )  
{  
$excludes = array\_filter( preg\_split( ‘/,/’, $exclude ), ‘trim’ );  
$c = array();

/\* This is where the error has thrown \*/  
foreach ( $controls as $control ) {

/\*\*/

if ( isset( $control[‘code’] ) && preg\_match( ‘/^\_\_/’, $control[‘code’] ) ) {  
continue;  
}  
if ( isset( $control[‘code’] ) && in\_array( $control[‘code’], $excludes ) ) {  
continue;  
}

$c[] = $control;  
}

return $c;  
}

&nbsp;

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [February 22, 2017, 2:43am UTC](https://forum.kintone.dev/t/cybozu-wp-to-kintone-error/28/2 "2017-02-22T02:43:35Z")

</div>

Update:

According to the developer at Digicube Inc., US account is out of support.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [February 25, 2017, 2:57am UTC](https://forum.kintone.dev/t/cybozu-wp-to-kintone-error/28/3 "2017-02-25T02:57:46Z")

</div>

I have resolved it by myself.

You need to change REST API URL according to your account country. &nbsp;

For example:

For US account, you need change URL domain from cybozu to kintone.

The code is in class-kintone-api.php.

Here is the sample.

function get\_form\_js():

/\* Change kintone API url by country \*/  
$uri = $\_SERVER[‘REQUEST\_URI’];

if (stripos($uri,‘jp’)){  
$url = sprintf(  
‘https://%[s.cybozu.com/k/v1/form.json?app=%d](http://s.cybozu.com/k/v1/form.json?app=%25d)’,  
$sub\_domain,  
$app\_id  
);  
}  
else {  
$url = sprintf(  
‘https://%[s.kintone.com/k/v1/form.json?app=%d](http://s.kintone.com/k/v1/form.json?app=%25d)’,  
$sub\_domain,  
$app\_id  
);  
}  
/\* End\*/

function sava\_data():

/\* Change kintone API url by country \*/  
$uri = $\_SERVER[‘REQUEST\_URI’];

if (stripos($uri,‘jp’)){  
$url = sprintf(  
‘https://%[s.cybozu.com/k/v1/form.json?app=%d](http://s.cybozu.com/k/v1/form.json?app=%25d)’,  
$sub\_domain,  
$app\_id  
);  
}  
else {  
$url = sprintf(  
‘https://%[s.kintone.com/k/v1/form.json?app=%d](http://s.kintone.com/k/v1/form.json?app=%25d)’,  
$sub\_domain,  
$app\_id  
);  
}  
/\* End\*/&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [February 28, 2017, 12:20am UTC](https://forum.kintone.dev/t/cybozu-wp-to-kintone-error/28/4 "2017-02-28T00:20:29Z")

</div>

Hi Mo, did this work in the end?  
As you’ve stated, there were around 4 lines in the class-kintone-api.php code that included a call to **"** https://%s. **_cybozu_**.com/k/v1 **"** that would only work for kintone for the Japanese region.

For US region kintone, this should be **"** https://%s. **_kintone_**.com/k/v1 **",** and that should be all of the change that would be needed.

Hope they fix it on the plug-in side though

&nbsp;

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [February 28, 2017, 12:36am UTC](https://forum.kintone.dev/t/cybozu-wp-to-kintone-error/28/5 "2017-02-28T00:36:20Z")

</div>

Yes. It works. I contacted the developer with this solutions but no response so far. I hope the fix will be released next update, too.
