我想将$remote\\u id读取为整数,$remote\\u id应该是执行metaweblog后的post\\u id。newpost。有人知道如何将数据转换为整数吗?
以下是代码:
$MAINURL = "http://mywordpress.com";
$USERNAME = "username";
$PASSWORD = "password";
function get_response($URL, $context) {
if(!function_exists(\'curl_init\')) {
die ("Curl PHP package not installed\\n");
}
/*Initializing CURL*/
$curlHandle = curl_init();
/*The URL to be downloaded is set*/
curl_setopt($curlHandle, CURLOPT_URL, $URL);
curl_setopt($curlHandle, CURLOPT_HEADER, false);
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $context);
/*Now execute the CURL, download the URL specified*/
$response = curl_exec($curlHandle);
return $response;
}
/*Creating the metaWeblog.newPost request which takes on five parameters
blogid,
username,
password*/
/*The title of your post*/
$title = "Sample Post from main site";
/*The contents of your post*/
$description = "This is a sample post from main site";
/*Forming the content of blog post*/
$content[\'title\'] = $title;
$content[\'description\'] = $description;
$content[\'categories\'] = array("mycategoryname");
$content[\'post_status\'] = \'publish\'; /* \'publish\' or \'draft\' or \'pending\'
/*Whether the post has to be published*/
$toPublish = true;
$request = xmlrpc_encode_request("metaWeblog.newPost",
array(1,$USERNAME, $PASSWORD, $content, $toPublish));
/*Making the request to wordpress XMLRPC of your blog*/
$xmlresponse = get_response($MAINURL."/xmlrpc.php", $request);
$remote_id = xmlrpc_decode($xmlresponse);
echo $remote_id;
$MAINURL = "http://mywordpress.com";
$USERNAME = "username";
$PASSWORD = "password";
function get_response($URL, $context) {
if(!function_exists(\'curl_init\')) {
die ("Curl PHP package not installed\\n");
}
/*Initializing CURL*/
$curlHandle = curl_init();
/*The URL to be downloaded is set*/
curl_setopt($curlHandle, CURLOPT_URL, $URL);
curl_setopt($curlHandle, CURLOPT_HEADER, false);
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $context);
/*Now execute the CURL, download the URL specified*/
$response = curl_exec($curlHandle);
return $response;
}
/*Creating the metaWeblog.newPost request which takes on five parameters
blogid,
username,
password*/
/*The title of your post*/
$title = "Sample Post from main site";
/*The contents of your post*/
$description = "This is a sample post from main site";
/*Forming the content of blog post*/
$content[\'title\'] = $title;
$content[\'description\'] = $description;
$content[\'categories\'] = array("mycategoryname");
$content[\'post_status\'] = \'publish\'; /* \'publish\' or \'draft\' or \'pending\'
/*Whether the post has to be published*/
$toPublish = true;
$request = xmlrpc_encode_request("metaWeblog.newPost",
array(1,$USERNAME, $PASSWORD, $content, $toPublish));
/*Making the request to wordpress XMLRPC of your blog*/
$xmlresponse = get_response($MAINURL."/xmlrpc.php", $request);
$remote_id = xmlrpc_decode($xmlresponse);
echo $remote_id;