Want to push posts through WP-API wordpressWhat does '--user' mean with curlWP REST API How to upload featured image?Can I install/update WordPress plugins without providing FTP access?WordPress plugin accessing WordPress URL remotely to send data acrossShopify Receipt and refund button grayed outwordpress REST API draft posts not showingUsing Contact Form 7 via WP REST APIWordPress Rest API get All PostsWordPress Rest API get total post countWordpress Multisite - API posts return an empty arrayPosting with Wordpress API RESTExtend post object in REST api in wordpress
Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?
I am looking for the correct translation of love for the phrase "in this sign love"
Where does the bonus feat in the cleric starting package come from?
What is Cash Advance APR?
On a tidally locked planet, would time be quantized?
What is the evidence for the "tyranny of the majority problem" in a direct democracy context?
Freedom of speech and where it applies
Aragorn's "guise" in the Orthanc Stone
Fear of getting stuck on one programming language / technology that is not used in my country
Count the occurrence of each unique word in the file
How much character growth crosses the line into breaking the character
Why electric field inside a cavity of a non-conducting sphere not zero?
Store Credit Card Information in Password Manager?
why `nmap 192.168.1.97` returns less services than `nmap 127.0.0.1`?
Why should universal income be universal?
How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?
Why did the EU agree to delay the Brexit deadline?
When a Cleric spontaneously casts a Cure Light Wounds spell, will a Pearl of Power recover the original spell or Cure Light Wounds?
How to explain what's wrong with this application of the chain rule?
If a character has darkvision, can they see through an area of nonmagical darkness filled with lightly obscuring gas?
What prevents the use of a multi-segment ILS for non-straight approaches?
Biological Blimps: Propulsion
Yosemite Fire Rings - What to Expect?
Is this toilet slogan correct usage of the English language?
Want to push posts through WP-API wordpress
What does '--user' mean with curlWP REST API How to upload featured image?Can I install/update WordPress plugins without providing FTP access?WordPress plugin accessing WordPress URL remotely to send data acrossShopify Receipt and refund button grayed outwordpress REST API draft posts not showingUsing Contact Form 7 via WP REST APIWordPress Rest API get All PostsWordPress Rest API get total post countWordpress Multisite - API posts return an empty arrayPosting with Wordpress API RESTExtend post object in REST api in wordpress
Greeting of the day,
I want to publish posts through an API call in wordpress without using the admin panel, i have used the http-auth plugin to manage the authorization into wordpress, also change the .htaccess file with the below code:
RewriteCond %HTTP:Authorization ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
and my script is this:
<?php
$process = curl_init('http://somewhereinsouth.com/wp-json/wp/v2/posts');
$data = array('slug' => 'welcome-to-the-jungle' , 'title' => 'Welcome to the Jungle' , 'content' => 'We welcome to you a better journey at the jungle.', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization' .'Basic'.base64_encode('admin:Best@xy123'));
// create the options starting with basic authentication
// curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
// make sure we are POSTing
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
// this is the data to insert to create the post
curl_setopt($process, CURLOPT_POSTFIELDS, $data_string);
// allow us to use the returned data from the request
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
// we are sending json
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
// process the request
$return = curl_exec($process);
curl_close($process);
// This buit is to show you on the screen what the data looks like returned and then decoded for PHP use
echo '<h2>Results</h2>';
print_r($return);
echo '<h2>Decoded</h2>';
$result = json_decode($return, true);
print_r($result);
And now i getting following Error while posting the posts at my website using this script. Error:
<h2>Results</h2><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BestViewsReviews | Restricted Site</title>
<link rel="stylesheet" href="http://somewhereinsouth.com/wp-content/plugins/http-auth/frontend/css/style.min.css" type="text/css">
</head>
<body class="http-restricted">
<p>You are not allowed to perform this action.</p>
</body>
</html><h2>Decoded</h2>
Please help me into this, thanks in advanced.
wordpress wordpress-rest-api
add a comment |
Greeting of the day,
I want to publish posts through an API call in wordpress without using the admin panel, i have used the http-auth plugin to manage the authorization into wordpress, also change the .htaccess file with the below code:
RewriteCond %HTTP:Authorization ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
and my script is this:
<?php
$process = curl_init('http://somewhereinsouth.com/wp-json/wp/v2/posts');
$data = array('slug' => 'welcome-to-the-jungle' , 'title' => 'Welcome to the Jungle' , 'content' => 'We welcome to you a better journey at the jungle.', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization' .'Basic'.base64_encode('admin:Best@xy123'));
// create the options starting with basic authentication
// curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
// make sure we are POSTing
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
// this is the data to insert to create the post
curl_setopt($process, CURLOPT_POSTFIELDS, $data_string);
// allow us to use the returned data from the request
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
// we are sending json
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
// process the request
$return = curl_exec($process);
curl_close($process);
// This buit is to show you on the screen what the data looks like returned and then decoded for PHP use
echo '<h2>Results</h2>';
print_r($return);
echo '<h2>Decoded</h2>';
$result = json_decode($return, true);
print_r($result);
And now i getting following Error while posting the posts at my website using this script. Error:
<h2>Results</h2><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BestViewsReviews | Restricted Site</title>
<link rel="stylesheet" href="http://somewhereinsouth.com/wp-content/plugins/http-auth/frontend/css/style.min.css" type="text/css">
</head>
<body class="http-restricted">
<p>You are not allowed to perform this action.</p>
</body>
</html><h2>Decoded</h2>
Please help me into this, thanks in advanced.
wordpress wordpress-rest-api
Can you try pass youradmin:password
as a curl--user
rather than a header, see more here on--user
stackoverflow.com/questions/36292406/…
– designtocode
Mar 8 at 7:19
can you please share snippet, how to use --user in above code.
– Manish Agarwal
Mar 8 at 8:31
You have commented outCURLOPT_USERPWD
, did this not work?
– designtocode
Mar 8 at 8:53
i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.
– Manish Agarwal
Mar 8 at 10:49
You need to pass the image in a different endpoint i.e./wp-json/wp/v2/media
and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…
– designtocode
Mar 8 at 13:15
add a comment |
Greeting of the day,
I want to publish posts through an API call in wordpress without using the admin panel, i have used the http-auth plugin to manage the authorization into wordpress, also change the .htaccess file with the below code:
RewriteCond %HTTP:Authorization ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
and my script is this:
<?php
$process = curl_init('http://somewhereinsouth.com/wp-json/wp/v2/posts');
$data = array('slug' => 'welcome-to-the-jungle' , 'title' => 'Welcome to the Jungle' , 'content' => 'We welcome to you a better journey at the jungle.', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization' .'Basic'.base64_encode('admin:Best@xy123'));
// create the options starting with basic authentication
// curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
// make sure we are POSTing
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
// this is the data to insert to create the post
curl_setopt($process, CURLOPT_POSTFIELDS, $data_string);
// allow us to use the returned data from the request
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
// we are sending json
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
// process the request
$return = curl_exec($process);
curl_close($process);
// This buit is to show you on the screen what the data looks like returned and then decoded for PHP use
echo '<h2>Results</h2>';
print_r($return);
echo '<h2>Decoded</h2>';
$result = json_decode($return, true);
print_r($result);
And now i getting following Error while posting the posts at my website using this script. Error:
<h2>Results</h2><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BestViewsReviews | Restricted Site</title>
<link rel="stylesheet" href="http://somewhereinsouth.com/wp-content/plugins/http-auth/frontend/css/style.min.css" type="text/css">
</head>
<body class="http-restricted">
<p>You are not allowed to perform this action.</p>
</body>
</html><h2>Decoded</h2>
Please help me into this, thanks in advanced.
wordpress wordpress-rest-api
Greeting of the day,
I want to publish posts through an API call in wordpress without using the admin panel, i have used the http-auth plugin to manage the authorization into wordpress, also change the .htaccess file with the below code:
RewriteCond %HTTP:Authorization ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
and my script is this:
<?php
$process = curl_init('http://somewhereinsouth.com/wp-json/wp/v2/posts');
$data = array('slug' => 'welcome-to-the-jungle' , 'title' => 'Welcome to the Jungle' , 'content' => 'We welcome to you a better journey at the jungle.', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization' .'Basic'.base64_encode('admin:Best@xy123'));
// create the options starting with basic authentication
// curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
// make sure we are POSTing
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
// this is the data to insert to create the post
curl_setopt($process, CURLOPT_POSTFIELDS, $data_string);
// allow us to use the returned data from the request
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
// we are sending json
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
// process the request
$return = curl_exec($process);
curl_close($process);
// This buit is to show you on the screen what the data looks like returned and then decoded for PHP use
echo '<h2>Results</h2>';
print_r($return);
echo '<h2>Decoded</h2>';
$result = json_decode($return, true);
print_r($result);
And now i getting following Error while posting the posts at my website using this script. Error:
<h2>Results</h2><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BestViewsReviews | Restricted Site</title>
<link rel="stylesheet" href="http://somewhereinsouth.com/wp-content/plugins/http-auth/frontend/css/style.min.css" type="text/css">
</head>
<body class="http-restricted">
<p>You are not allowed to perform this action.</p>
</body>
</html><h2>Decoded</h2>
Please help me into this, thanks in advanced.
wordpress wordpress-rest-api
wordpress wordpress-rest-api
asked Mar 8 at 5:04
Manish AgarwalManish Agarwal
287
287
Can you try pass youradmin:password
as a curl--user
rather than a header, see more here on--user
stackoverflow.com/questions/36292406/…
– designtocode
Mar 8 at 7:19
can you please share snippet, how to use --user in above code.
– Manish Agarwal
Mar 8 at 8:31
You have commented outCURLOPT_USERPWD
, did this not work?
– designtocode
Mar 8 at 8:53
i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.
– Manish Agarwal
Mar 8 at 10:49
You need to pass the image in a different endpoint i.e./wp-json/wp/v2/media
and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…
– designtocode
Mar 8 at 13:15
add a comment |
Can you try pass youradmin:password
as a curl--user
rather than a header, see more here on--user
stackoverflow.com/questions/36292406/…
– designtocode
Mar 8 at 7:19
can you please share snippet, how to use --user in above code.
– Manish Agarwal
Mar 8 at 8:31
You have commented outCURLOPT_USERPWD
, did this not work?
– designtocode
Mar 8 at 8:53
i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.
– Manish Agarwal
Mar 8 at 10:49
You need to pass the image in a different endpoint i.e./wp-json/wp/v2/media
and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…
– designtocode
Mar 8 at 13:15
Can you try pass your
admin:password
as a curl --user
rather than a header, see more here on --user
stackoverflow.com/questions/36292406/…– designtocode
Mar 8 at 7:19
Can you try pass your
admin:password
as a curl --user
rather than a header, see more here on --user
stackoverflow.com/questions/36292406/…– designtocode
Mar 8 at 7:19
can you please share snippet, how to use --user in above code.
– Manish Agarwal
Mar 8 at 8:31
can you please share snippet, how to use --user in above code.
– Manish Agarwal
Mar 8 at 8:31
You have commented out
CURLOPT_USERPWD
, did this not work?– designtocode
Mar 8 at 8:53
You have commented out
CURLOPT_USERPWD
, did this not work?– designtocode
Mar 8 at 8:53
i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.
– Manish Agarwal
Mar 8 at 10:49
i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.
– Manish Agarwal
Mar 8 at 10:49
You need to pass the image in a different endpoint i.e.
/wp-json/wp/v2/media
and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…– designtocode
Mar 8 at 13:15
You need to pass the image in a different endpoint i.e.
/wp-json/wp/v2/media
and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…– designtocode
Mar 8 at 13:15
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057017%2fwant-to-push-posts-through-wp-api-wordpress%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057017%2fwant-to-push-posts-through-wp-api-wordpress%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you try pass your
admin:password
as a curl--user
rather than a header, see more here on--user
stackoverflow.com/questions/36292406/…– designtocode
Mar 8 at 7:19
can you please share snippet, how to use --user in above code.
– Manish Agarwal
Mar 8 at 8:31
You have commented out
CURLOPT_USERPWD
, did this not work?– designtocode
Mar 8 at 8:53
i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.
– Manish Agarwal
Mar 8 at 10:49
You need to pass the image in a different endpoint i.e.
/wp-json/wp/v2/media
and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…– designtocode
Mar 8 at 13:15