• Andrei G.

    (@27shutterclicks)


    Hi,

    I installed the plugin and entered the YMLP credentials on the settings screen.

    Then, I tried to add a new feed and got a strange warning within the Select a YMLP feed dropdown menu. The dropdown menu had two entries that looked something like:

    Warning: Illegal string offset “GroupName” in … /ymlp/ymlp.php

    Obviously, the actual YMLP group names were not displayed and when selecting one of the warning choices and then attempting to select a Gravity Form form from the next dropdown menu, nothing would happen. There would be just a circle spinning continously.

    I verified the username and API key and they were correct (according to the client on behalf on which I was setting this up and who had provided them).

    Now, I poked around the plugin code and found that somewhere around line 1259 of ymlp.php there is a call to get the list of groups via the api:

    $lists = $api->GroupsGetList();

    Then, there’s a check to see if there are no lists and if so to display the error:

    if (!$lists){
    
                        echo __("Could not load YMLP contact lists. <br/>Error: ", "gravity-forms-ymlp");
    
                        echo isset($api->ErrorMessage) ? $api->ErrorMessage : '';
    
                    }

    The, all the logic happens in the else of the above if (if there are indeed lists).

    To troubleshoot it, I added a variable dump to understand the nature of $lists in my scenario and see what it contained, if anything (this was added on line 1260, right after the call to list the groups:

    echo "<pre>";
    			print_r($lists);
    			echo "</pre>";

    This resulted in the following being displayed in the add new feed screen:

    Array
    (
        [Code] => 101
        [Output] => API access is disabled.  To enable it, select API under the Configuration tab in your account.
    )

    So that means that if the plugin is unable to get the lists via the api (like in this example when API access is disabled in the YMLP account), the $lists variable/array will not be empty.

    Thus, the check “if (!$lists){” will in fact be ignored (because the array is not empty) and the “else” be executed, except that there are no actual lists to display and the result will be the unfriendly illegal string offset warning.

    Now, I was able to access the actual YMLP account in question and verify that indeed API access was not enabled (although the API key was displayed in the API section). Enabling the API access in the YMLP account fixed the issues I was having, but I would have had no idea this was the cause of everything had I not gone through this entire process.

    As a regular user, I would have simply assumed that this is a bad/broken/incompatible plugin and uninstalled it immediately.

    It would be great if you could correct the plugin to also check if $lists may not empty but instead contain an error message. Something like:

    } elseif ($lists[Code]) { //check for failure code
    
    	echo "Error: " . $lists[Output]; //display the failure message
    
    }

    According to the YMLP documentation, the following is returned in case of failure for the Groups.GetList() api call:

    Failure:
    
    Returncode 100 : "Invalid or missing API key"
    Returncode 101 : "API access is disabled"
    Returncode 102 : "API access not allowed from this IP address ([IP])"

    Hope this helps and thank you for this useful plugin.

    https://ww.wp.xz.cn/plugins/ymlp/

The topic ‘Illegal string offset error "GroupName" when adding a new feed’ is closed to new replies.