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













1















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.










share|improve this question






















  • 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















1















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.










share|improve this question






















  • 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













1












1








1








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.










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 5:04









Manish AgarwalManish Agarwal

287




287












  • 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

















  • 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
















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












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
);



);













draft saved

draft discarded


















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















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme