0

我已经设法连接到 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 ) 

希望这是一个。感谢您的支持

4

1 回答 1

2

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

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

参考

于 2013-08-05T10:45:13.897 回答