tepkool01 / simple-linkedinphp

Automatically exported from code.google.com/p/simple-linkedinphp
0 stars 0 forks source link

Parse error: syntax error, unexpected T_FUNCTION in /srv/www/htdocs/Oauth/linkedin_3.2.0.class.php on line 259 #24

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Pasted in API key & secret
2. Ran demo.php

What is the expected output? What do you see instead?
Parse error: syntax error, unexpected T_FUNCTION in 
/srv/www/htdocs/Oauth/linkedin_3.2.0.class.php on line 259

What version of the product are you using? On what operating system?
3.2.0, SLES 10 64-bit

Please provide any additional information below.

Original issue reported on code.google.com by swai...@gmail.com on 20 Mar 2012 at 5:36

GoogleCodeExporter commented 9 years ago
look in that line:
array_walk($http_code_required, function($value, $key) {
        if(!is_int($value)) {
                throw new LinkedInException('LinkedIn->checkResponse(): $http_code_required must be an integer or an array of integer values');
            }
      });

you need an update to php 5.3 or make changes in the lib.

Original comment by ottod...@googlemail.com on 22 Mar 2012 at 2:53

GoogleCodeExporter commented 9 years ago
While the code states that PHP 5+ is required, the use of the lambda function 
in the array_walk call is PHP 5.3+ (AFAIK). It should suffice to replace that 
call with something like 

foreach ($http_code_required as $value) {
    if(!is_int($value)) {
        throw new LinkedInException('LinkedIn->checkResponse(): $http_code_required must be an integer or an array of integer values');
    }
}

Original comment by joor.loo...@gmail.com on 24 Mar 2012 at 2:35

GoogleCodeExporter commented 9 years ago
foreach ($http_code_required as $value) {
    if(!is_int($value)) {
        throw new LinkedInException('LinkedIn->checkResponse(): $http_code_required must be an integer or an array of integer values');
    }
}

Works like a charm.. Thanks joor.loo...

Saved me alot of time!!

Original comment by jeffrey....@gmail.com on 31 Mar 2012 at 2:17

GoogleCodeExporter commented 9 years ago
thanks for the php < 5.3 fix.

Original comment by oasis.fr...@gmail.com on 7 Sep 2012 at 11:01

GoogleCodeExporter commented 9 years ago
Thanks man...it's works for me...and saved a lot time of mine :)

Original comment by brijesh....@gmail.com on 14 Sep 2012 at 4:53

GoogleCodeExporter commented 9 years ago
Thanks man..it works fine..awesome :)

Original comment by JJai...@gmail.com on 19 Jan 2013 at 10:50

GoogleCodeExporter commented 9 years ago
With PHP Version 5.2.6, I just defined a function and inserted the call in the 
array_walk function:

if(is_array($http_code_required)) {
  function somefunction($value, $key) {
    if(!is_int($value)) {
      throw new LinkedInException('LinkedIn->checkResponse(): $http_code_required must be an integer or an array of integer values');
    }
  }
  array_walk($http_code_required, somefunction($value, $key));
}

according to the official PHP documentation 
(http://php.net/manual/en/function.array-walk.php):

bool array_walk ( array &$array , callable $funcname [, mixed $userdata = NULL 
] )

the second parameter is the function name :)
Probably in PHP > 5.3 it's possible to define the function directly in the 
array_walk..

Original comment by and...@norz.it on 13 Feb 2013 at 10:32

GoogleCodeExporter commented 9 years ago
I have replace the function 

foreach ($http_code_required as $value) {
    if(!is_int($value)) {
        throw new LinkedInException('LinkedIn->checkResponse(): $http_code_required must be an integer or an array of integer values');
    }
}

the issue is gone away, but still i am unable to login by linked, while click 
on linkedin button its doing nothing abut redirecting me on the same url with 
"?lType=initiate"  passed in my url..

please help me how can i solve this issue.

Original comment by tech.to...@gmail.com on 3 May 2013 at 5:54

GoogleCodeExporter commented 9 years ago
I did it this way: (This is line 257-267 in my linkedin_3.2.0.class.php now.)
        // check passed data
    if (!function_exists('ensureInt')) {
      function ensureInt ($value, $key) { //original had this as an anonymous function in array_walk below.
        if(!is_int($value)) {
          throw new LinkedInException('LinkedIn->checkResponse(): $http_code_required must be an integer or an array of integer values');
        }
      }
    }       

    if(is_array($http_code_required)) {
          array_walk($http_code_required, 'ensureInt');

Original comment by TecB...@gmail.com on 20 Dec 2013 at 1:46

GoogleCodeExporter commented 9 years ago
Thanks a lot

Original comment by Deepanja...@gmail.com on 25 Mar 2015 at 4:15