I want post tweets into facebook using php curl , this is my snippet I used for posting tweet into FB - FB CURL SNIPPET
But i am not find any updated tweet in my facebook,
am not sure but i thing somthing goes wrong,
Can you tell me, snippet is correct one or not?
Thanks
This calls for debugging.
First port of call: It could be that the cookies are not saved: Check whether the script actually generates a my_cookies.txt file. If it doesn't, create an empty one and do a chmod 777 on it.
Second port of call: curl_error().
Replace every curl_exec() call in the snippet by this:
$success = curl_exec(....... your options .....);
if (!$success) echo "CURL Error: ".curl_error();
this might give you some pointers as to what goes wrong.
However, seeing as the script tries to imitate a browser instead of using an API, it could be that the structure of the submission form has changed on Facebooks's side, in which case you'll have to parse the output cURL gives you and see what goes wrong.
All in all, if there is any way to do this cleanly through an API - I don't know whether there is - it would be much preferable to this.
Related
We have a contact.html form that uses reCaptcha v2, whose backend processing is in a php file.
I've taken enough steps to understand that when we send the verification to google's api, the response comes back empty. Below is code that gave me this proof.
$url = 'https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST["g-recaptcha-response"].'&remoteip='.$_SERVER['REMOTE_ADDR'];
$verify = file_get_contents($url);
echo $url;
if (empty($verify)) echo 'Failed to fetch data';`
However, when I manually enter the url into a browser, I get a JSON response back that indicates success.
What, then, is the difference? Why would file_get_contents return empty if a simple get request from a Chrome browser give me trouble?
I have read that file_get_contents is synchronous, so I wouldn't expect this is just a noob error on waiting for the response.
Any help would be appreciated, this is my very first time working with PHP. It's not hard, but I may be missing something vital.
Sorry everyone, I can't understand why, but the problem was in the method used to access the site verify.
Using curl syntax, I finally got it working.
Change the configuration in php.ini file and don't need curl.
allow_url_fopen=0 to allow_url_fopen=1
Im Lost Please, How do I resolve the following on CodeIgniter using
REST-cliente library (REST).
I try send POST, the webApp or WebResourse is based on (ASP.net), so the idea is this:
getUser()
function getUser($ID){
//set config of the URL
$config = array('server' => 'http://www.example.com/app/webapp/);
//initialize
$this->rest->initialize($config);
//now here is my problem look at this Im lost, I try this but I dont understand:
$postData = '__VIEWSTATE=/DKEKCdmdaEKEKEcnaEKEqkencKJE&'.
'__EVENTVALIDATE=/DWRRKCkadjeEWWrjrDSJEJeW&'.
'buttonSearch=search&'.
'textFieldUserID='.$ID.';
$this->rest->option(CURLOPT_POSTFIELDS, $postData);
$this->rest->post('query/user.apsx');
//When run this, I use debug but NO show ERROR, this only return content html of page whitout query of user data.
$this->rest->debug();
Note: I user library rest and curl is named within constructor. I use this for request GET and work perfectly. but I want to do POST
$this->load->library('curl');
$this->load->library('rest');
The library:
https://github.com/philsturgeon/codeigniter-restclient
Thanks.!!!
As you stated in your question:
//When run this, I use debug but NO show ERROR, this only return
content html of page whitout query of user data.
$this->rest->debug();
So, if you received HTML but not the desired data, the problem is the server you are asking to. It's more than sure that you're not doing the right request, but is weird because they should show you what is wrong.
Other thing would be, could you paste the given answer? Just to know what are the errors, if any.
I have signed up to a synonym API.. see the details on this page
I am having trouble implementing this in my php code.
If I copy and paste the link into the web browser, I can see the results no problem.
Instead of typing the word in manually, I wish to have a variable in the link with the relevant word i.e. $variable_with_word_stored as shown below.
http://words.bighugelabs.com/api/2/xxxxxxxx/$variable_with_word_stored/php
//format could be php (I would unserialize)..or json..I could decode it?
Any ideas guys? Thanks.
It sounds like you mean you want the result from calling that webpage and store it in a variable. What you should be looking to do is sending a http get request to that page within the code.
Check out using curl with php, you can send a http request to your requested url, capture the result back and parse it through json_decode
http://php.net/manual/en/curl.examples-basic.php
try it like this, maybe that you dont need curl:
$key = "xxxxxxxx";
$word = "love";
echo file_get_contents("http://words.bighugelabs.com/api/2/$key/$word/php");
I am quite frustrated with a very weird issue. I am trying to do a very simple thing here. I would like to post a form to an endpoint. I tried using the following command:
curl -d "Contact=Aditya&address1=1510 E. 9th Street&address2=Apt. 111&city=Tucson&state=AZ&zip=85719&Phone1=5207849817&Phone2=1237849812&email=aditya15417#yahoo.com&key2=09 New Lead&key5=AmpushU&uhsgradyr=1950&uhighlevel=AA&ucourseint=BA Internet Mktg&uCampaignID=Herlambang&utextperm=YES&uleaddate=20110910&uleadtime=19:18 PST" http://dev.degreeamerica.com/candidate_test.php
And yes it succeeds just fine, however when I try it via the site it gives me an error. Can someone tell me what I did wrong? The parameter I have on the curl is just something I copy and paste from firebug POST request, so the parameter is all the same.
Is there something wrong with me doing the AJAX?
You can't receive the results of a cross-domain post like that. Your page is on adityaherlambang.com, but you're posting to degreeamerica.com, so you can't get the results
One solution is to use a server-side proxy on adityaherlambang.com, and post using libcurl to degreeamerica.com, while returning whatever kind of status you want to your own site's JavaScript.
How would I go about writing a simple PHP bot that could login in and recieve all the cookies sent by the server? ... and then send them back when required?
Any suggestions would be appreciated.
First of all, your question is too broad and lacking in detail to really answer effectively. That said, I'll give it a try.
Not knowing what exactly you mean by "log in", I assume you want the script to be able to post some data to another script via an HTTP request. The CURL Library is good for that. It is able to post data and handle cookies.
Edit: Got ninja'd by Zed. ;)
If for some reason you cannot use the curl extension on your server (extension not installed), you can use a class such as Snoopy which will still allow you to either use the curl binaries or use sockets to retrieve the information.
Snoopy handles cookies.
As for the writing the bot itself, it's just a question of sending the proper requests. Here is an example with Snoopy:
$snoopy = new Snoopy;
// The following needs to reflect the form configuration of the site
$login = array('usr' => 'hi', 'pwd' => 'hello');
if($snoopy->submit('http://example.com/login', $login) === false) {
// output the response code
die($snoopy->response_code . ':' . $snoopy->error);
}
//Request succeeded (doesn't mean we are logged in)
// output the results
echo $snoopy->results;
// Check the results to see if you are logged in and
// Continue using $snoopy.
// It will pass the proper cookies for the next requests.
With the help of the cURL library?