2

我正在尝试从linkedin 获取信息,但我不断收到以下错误?

我已经四处搜索,但我看到的修复仅适用于那些在使用 djangopiston 时遇到错误的人。谁能帮我解决这个问题?

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/jobs/1/match/

Django Version: 1.3.1
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.flatpages',
 'django.contrib.admin',
 'django.contrib.staticfiles',
 'compress',
 'south',
 'filer',
 'easy_thumbnails',
 'registration',
 'socialregistration',
 'socialregistration.contrib.facebook',
 'socialregistration.contrib.twitter',
 'socialregistration.contrib.linkedin',
 'socialregistration.contrib.openid',
 'privatebeta',
 'api',
 'profiles',
 'jobs',
 'misc']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.csrf.CsrfResponseMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'socialregistration.contrib.facebook.middleware.FacebookMiddleware',
 'socialregistration.contrib.linkedin.middleware.LinkedInMiddleware',
 'misc.middleware.SubdomainMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')


    Traceback:
    File "/home/arlus/jobmatch/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
    File "/home/arlus/jobmatch/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
    File "/home/arlus/jobmatch/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)
    File "jobs/views.py" in match
  60.         matches = linkedin_api.get_connections(fields=['headline', 'summary',]).encode('utf-8')
    File "../lib/linkedin/linkedin.py" in get_connections
  291.             response = self._do_normal_query(raw_url)
    File "../lib/linkedin/linkedin.py" in _do_normal_query
  757.                                     signature_dict, self._access_token_secret, method, update=False)
    File "../lib/linkedin/linkedin.py" in _calc_signature
  789.         hashed = hmac.new(self._calc_key(token_secret), signature_base_string, sha)
File "/usr/lib/python2.7/hmac.py" in new
  133.     return HMAC(key, msg, digestmod)
File "/usr/lib/python2.7/hmac.py" in __init__
  72.         self.outer.update(key.translate(trans_5C))

    Exception Type: TypeError at /jobs/1/match/
    Exception Value: character mapping must return integer, None or unicode
4

2 回答 2

0

很难说,但是在某个地方,无论是在 urls.py 和 views.py 中,你都应该检查传递的对象的类型。它可能没有预期值。

例如 /jobs/1/match,1 可能预期为 int,但结果为 str。

于 2012-10-25T03:36:09.370 回答
0

可能是因为文本是作为 unicode 输入的,试试key.encode.('UTF-8')

于 2017-04-28T12:31:55.223 回答