Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Linkedin邀请API内部服务器错误_Php_Api_Linkedin - Fatal编程技术网

Php Linkedin邀请API内部服务器错误

Php Linkedin邀请API内部服务器错误,php,api,linkedin,Php,Api,Linkedin,哟! 我正在尝试使用linkedin邀请api,允许用户使用电子邮件地址从我的应用程序连接linkedin。我能够找到人,访问api等等。但是我不能让邀请工作。我正在使用php(Laravel) 我以linkedin文档()中的示例为基础。我使用JSON(包含与示例相同的信息)在帖子中发送数据 我请求允许使用w_消息,post works和我的变量包含正确的信息。我得到一个内部服务器错误作为结果 $data = array( "recipients" => array(

哟!

我正在尝试使用linkedin邀请api,允许用户使用电子邮件地址从我的应用程序连接linkedin。我能够找到人,访问api等等。但是我不能让邀请工作。我正在使用php(Laravel)

我以linkedin文档()中的示例为基础。我使用JSON(包含与示例相同的信息)在帖子中发送数据

我请求允许使用w_消息,post works和我的变量包含正确的信息。我得到一个内部服务器错误作为结果

$data = array(
        "recipients" => array(
                "values" => array(
                    "person" => array(
                        "_path" => "/people/email=".$email,
                        "first-name" => $firstname,
                        "last-name" => $lastname
                        )
                    )
            ),
        "subject" => "Bla",
        "body"=> "BlaBLa", 
        "item-content" => array(
                "invitation-request" => array(
                        "connect-type" => "friend"
                    )
            )
        ); 

    $dataString = json_encode($data);

    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-type: application/json\r\n".
                          "Connection: close\r\n" .
                          "Content-length: " . strlen($dataString) . "\r\n",
            'content' => $dataString
        )
    );

    $params = array('oauth2_access_token' => Session::get('access_token'),
        'format' => 'json'
        );


    $url = "https://api.linkedin.com/v1/people/~/mailbox".'?' . http_build_query($params);
    $context = stream_context_create($opts);
    $result = file_get_contents($url, false, $context);
    Log::info($result);

    return Response::json(array("invite" => "sent"));

我假设我做错了什么,但我真的不知道该往哪里看。

看起来像是手动操作的,您是否尝试过使用一个经过测试的第三方库,比如
simple linkedinphp
——一个基于PHP的LinkedIn API包装器

用法:

// Connect
$API_CONFIG = array(
  'appKey'       => '<your application key here>',
  'appSecret'    => '<your application secret here>',
  'callbackUrl'  => NULL 
);
$linkedin = new LinkedIn($API_CONFIG);

// Send Invite
$linkedin->invite($method, $recipient, $subject, $body, $type = 'friend');
//连接
$API_CONFIG=array(
“appKey'=>”,
“appSecret'=>”,
“callbackUrl”=>NULL
);
$linkedin=新的linkedin($API\U配置);
//发送邀请
$linkedin->invite($method、$recipient、$subject、$body、$type='friend');
文件: