使用php在我的文本字段中显示linkedin详细信息

时间:2013-08-05 10:33:54

标签: php api linkedin

我已设法与Linkedin APi连接,因此我可以使用以下代码获取用户详细信息。

 $response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url,email-address,phone-numbers)');
        if($response['success'] === TRUE) {
          $response['linkedin'] = new SimpleXMLElement($response['linkedin']);

之后,我需要将检索到的详细信息显示在这样的文本字段中。

<table border="1">
                    <tr>
                        <td>Name</td>
                        <td><?php echo $response['linkedin']->id;   ?></td>
                    </tr>


                    <tr>
                        <td>first Name</td>
                        <td><?php  echo $response['linkedin']->first-name; ?></td>
                    </tr>


                    <tr>
                        <td>Email</td>
                        <td><?php  echo $response['linkedin']->email-address; ?></td>
                    </tr>


          </table>

ID正确显示,但未显示其他详细信息。 任何人都可以帮助这个。 提前谢谢

这是xml输出

this is : Array ( [linkedin] => KmRPC6CWFV Dam Path0 http://m.c.lnkd.licdn.com/mpr/mprx/0_TLYPQpjA4IBXz8ZqfCOhQxS04wrNB8dq_TE2Qxj8FDXkegggdXONDimxH0Wm9QKwqbH486ySW47__SJO ****@yahoo.com mobile +947123452 [info] => Array ( [url] => https://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-url,email-address,phone-numbers) [content_type] => text/xml;charset=UTF-8 [http_code] => 200 [header_size] => 205 [request_size] => 500 [filetime] => -1 [ssl_verify_result] => 20 [redirect_count] => 0 [total_time] => 1.482 [namelookup_time] => 0 [connect_time] => 0.374 [pretransfer_time] => 1.076 [size_upload] => 0 [size_download] => 538 [speed_download] => 363 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 1.466 [redirect_time] => 0 ) [oauth] => Array ( [header] => Authorization: OAuth realm="http%3A%2F%2Fapi.linkedin.com",oauth_version="1.0",oauth_nonce="a484c4f1360fce43994eac522452b3b1",oauth_timestamp="1375865879",oauth_consumer_key="dxmlx1mg2xoz",oauth_token="70b05d77-fa98-49eb-bada-4be9d8533f29",oauth_signature_method="HMAC-SHA1",oauth_signature="05UWwjC1jC7lZT%2BBa8nWk8Isiz8%3D" [string] => GET&https%3A%2F%2Fapi.linkedin.com%2Fv1%2Fpeople%2F~%3A%28id%2Cfirst-name%2Clast-name%2Cpicture-url%2Cemail-address%2Cphone-numbers%29&oauth_consumer_key%3Ddxmlx1mg2xoz%26oauth_nonce%3Da484c4f1360fce43994eac522452b3b1%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1375865879%26oauth_token%3D70b05d77-fa98-49eb-bada-4be9d8533f29%26oauth_version%3D1.0 ) [success] => 1 ) 

希望这是感谢您的支持

1 个答案:

答案 0 :(得分:2)

你不能在PHP中使用这样的连字符。 试试这个:

<?php  echo $response['linkedin']->{'first-name'}; ?>

Reference