2016-05-07 3 views
0

私はこのチュートリアル以下のLinkedInの上でautopostしようとしている、としています:自動LinkedInのは、未定義の関数のhttp()にエラーコールを取得し、PHPを使用してのステータスを公開する方法

:私はこのエラーを得た http://www.tricksofit.com/2015/09/get-user-access-token-for-linkedin#.Vy13KYR97IU

致命的なエラー:行23の未定義の関数http()をC:\ xammpp \ xampp \ htdocs \ linkedin \ one \ callback.phpに呼び出してください。

誰かに教えてください。

require_once("OAuth.php"); 

$data = array(
'consumer_key' => 'xxxxxxxxxxxxx', 
'consumer_secret' => 'xxxxxxxxxxx', 
'callback_url' => 'http://localhost/linkedin/one/callback.php' 
); 
if(isset($_REQUEST['oauth_verifier'])){ 

$data['oauth_token'] = $_SESSION['oauth_request_token']; 
$data['oauth_token_secret'] = $_SESSION['oauth_request_token_secret']; 

$method = new OAuthSignatureMethod_HMAC_SHA1(); 
$consumer = new OAuthConsumer($data['consumer_key'],  $data['consumer_secret']); 
$token = new OAuthConsumer($data['oauth_token'],$data['oauth_token_secret']); 

$args = array(); 
$request = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', "https://api.linkedin.com/uas/oauth/accessToken", $args); 
$request->set_parameter("oauth_verifier", $_REQUEST['oauth_verifier']); 
$request->sign_request($method, $consumer, $token); 
$request = http($request->to_url(),false); 

function http($url, $post_data = null) { 
    $ch = curl_init(); 

    if(defined("CURL_CA_BUNDLE_PATH")) 
    curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH); 

    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    if(isset($post_data)) 
    { 
     curl_setopt($ch, CURLOPT_POST, 1); 
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
    } 

    $response = curl_exec($ch); 
    curl_close($ch); 

    return $response; 
} 

parse_str($request, $token); 

$tokens = new OAuthConsumer($token['oauth_token'],  $token['oauth_token_secret'], 1); 
$access_token = serialize($tokens); 
} 
+0

機能は、それが呼び出された後に注文を変更しようとしている、右定義するのですか? –

答えて

1

このケースはundefined functionで、別の機能を定義するとエラーが発生します。

function foo() { 

    $request = http(); 
    echo $request; 

    function http() { 
     return "aaa"; 
    } 

} 
foo(); 

あなたの現在の関数のスコープ外http()を定義する必要があります。

function foo(){ 
    $request = http(); 
    echo $request; 
} 

function http() { 
    return "aaa"; 
} 

foo(); 
+0

ありがとう。@ PetrHejda –

関連する問題