0
誰かがcurlやそれに類似するPHP 5.6で利用可能な次のリクエストを書き直すのを手伝ってもらえますか?私はPHPのhttpリクエストで新しく、HttpRequestクラスを使用することができません。なぜなら、それはサーバー上に見つからないためです。その他の提案も大歓迎です。おそらく既に図書館がありますか?VuforiaのHTTP要求を書き直してください
$path = "content/images/calendarmotiv/";
$fail = true;
$tmp = $_FILES['imagetarget']['tmp_name'];
$name = basename($_FILES['imagetarget']['name']);
if(move_uploaded_file($tmp, $path.$name))
{
// http request body
$now = new DateTime('NOW');
$body = json_encode(array(
"name" => $name,
"width" => 1024.0,
"image_url" => base64_encode($path.$name),
"active_flag" => 1,
"application_metadata_url" => base64_encode($_POST["metadata"]))
);
$http_verb = "POST";
$content_md5 = md5($body);
$content_type = "application/json";
$date = str_replace("+0000", "GMT", $now->format(DateTime::RFC1123));
$request_path = "<a href='https://vws.vuforia.com/targets'> https://vws.vuforia.com/targets</a>";
// auth string for header
$string_to_sign = $http_verb . "\n" . $content_md5 . "\n" . $content_type . "\n" . $date . "\n" . $request_path;
$secret_key = "mykey";
$signature = hash_hmac("sha1", $string_to_sign, $secret_key);
$authstring = "VWS " . $secret_key . ":" . $signature;
// the request
$request = new HttpRequest($request_path, HttpRequest::METH_POST);
$request->setContentType($content_type);
$request->setBody($body);
$request->addHeaders(array(
"Date" => $date,
"Authorization" => $authstring));
$request->send();
echo $request->getRequestMessage();
echo $request->getResponseMessage();
}
はcURLので構築された私は、HTTPの拡張機能が正常に動作すべきだと思うと仮定。私に飛びついたことはHTMLマークアップである '$ request_path'値です。 – ficuscr
はい、そうですが、 '$ request_path'はおそらくHTMLマークアップであってはなりません。私はちょうど私が必要としているので、[リンク](https://developer.vuforia.com/forum/general-discussion/help-me-use-vws-api-php)のコードをコピーしました。しかし、私はこれを実行することができませんでした。 –
私はこのケースで使うことができる[ライブラリ](https://github.com/jacobtabak/curl-vuforia-client/blob/master/VuforiaClient.php)を見つけましたが、Vuforiaからの私の唯一の応答は** "result_code": "BadImage" **と "transaction_id"はアップロードする画像に関係なくターゲットは作成されません。私はこれ以上の情報なしでこれをどのようにデバッグするのか分かりません。誰もそれを見ている? –