3

Sugarcrm REST API を介してカスタム モジュール データを取得しようとしていますが、ドキュメント コードでログインすることさえできないため、ドキュメントに記載されているのと同じことを試しました。

    <?php

// specify the REST web service to interact with
$url = 'localhost/~jmertic/sugarcrm/service/v4_1/rest.php';

// Open a curl session for making the call
$curl = curl_init($url);

// Tell curl to use HTTP POST
curl_setopt($curl, CURLOPT_POST, true);

// Tell curl not to return headers, but do return the response
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// Set the POST arguments to pass to the Sugar server
$parameters = array(
    'user_auth' => array(
        'user_name' => 'username',
        'password' => md5('password'),
        ),
    );
$json = json_encode($parameters);
$postArgs = array(
    'method' => 'login',
    'input_type' => 'JSON',
    'response_type' => 'JSON',
    'rest_data' => $json,
    );
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs);

// Make the REST call, returning the result
$response = curl_exec($curl);

// Convert the result from JSON format to a PHP array
$result = json_decode($response);
if ( !is_object($result) ) {
    die("Error handling result.\n");
}
if ( !isset($result->id) ) {
    die("Error: {$result->name} - {$result->description}\n.");
}

// Get the session id
$sessionId = $result->id;

セットアップに合わせてユーザー名、パスワード、URL を変更しましたが、次のエラーが表示されます

No direct script access allowed

これをウェブで検索しようとしましたが、関連する解決策が見つかりませんでした。私はsugarCRM 6.5.0RC2バージョンを使用しています

よろしく、 アナンド・ジョシ

4

2 に答える 2

0

この線じゃないかな…

$url = 'http://yoursugarinstance/service/v4_1/rest.php';
于 2012-07-06T15:16:35.010 に答える