function modify(.......)
{
$mcontact = file_get_contents( "https://test.httpapi.com/api/contacts/modify.json?auth-userid=$uid&auth-password=$pass&contact-id=$cid&name=$name &company=$company&email=$email&address-line-1=$street&city=$city&country=$country&zipcode=$pincode&phone-cc=$countryCodeList[$phc]&phone=$phone" );
$mdetails = json_decode( $mcontact, true );
return $mdetails;
}
using this modify function, displays warning mesage
Warning: file_get_contents(https://...#hihfg.com&address-line-1=3,dfgdf,fgdf&city=dfgfd&country=India&zipcode=641005&phone-cc=91&phone=756657)
[function.file-get-contents]: failed to open stream: HTTP request failed!
HTTP/1.0 400 Bad request in /home/gfdgfd/public_html/new_one/customer/account/class.whois.php
on line 49
Please help me, modify contact details..
HTTP/1.0 400 Bad request - everything you need to know: You are sending a request the server doesn't like.
Are you sure it accepts a GET request and doesn't require POST? Is the URL correct?
Your URL is wrong. You have an additional space character: &name=$name &company=$company. Remove it.
Related
I am trying to fetch some data like first name, last name from LinkedIn. I am using the below code for the same. But I am getting NULL in response. I tried some solutions from SO and other websites but none of them worked.
Below is the code I am using:-
$url = 'http://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-urls::(original),headline,public-profile-url,location,industry,positions,email-address)?format=json&outh2_access_token='.$accessToken;
$user = file_get_contents($url,false);
var_dump(json_decode($user));
die();
Below is the response that I am getting.
[16-Jul-2018 12:27:20 Europe/London] PHP Warning: file_get_contents(http://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-urls::(original),headline,public-profile-url,location,industry,positions,email-address)?format=json&outh2_access_token=###########): failed to open stream: HTTP request failed! HTTP/1.0 401 Unauthorized
Basically what I want is to fetch the data from LinkedIn using php, if anybody has done this before please share the solution with me.
I'm trying to develop and Instagram application but I'm struggling to get a json inserting the access token via variable.
That's my code:
$personal = json_decode(file_get_contents('https://api.instagram.com/v1/users/self/?access_token={$accesstoken}'));
And the error that I receive is this:
PHP Warning: file_get_contents(https://api.instagram.com/v1/users/self/?access_token={$accesstoken}): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
I already tried to see if I get the variable $accesstoken from the previous form and it's all right, because if I echo-it on the page it pops up.
I tried the function preg_replace to understand if the problem were the white spaces, but nothing.
I don't want to use cURL if it is not mandatory.
What's wrong with the code (and me)?
Thanks in advance!
Edit:
As I answered to #FirstOne: yes, I already tried to put the variable (access token) manually and in this way it works.
I want to make a http request but i always get
failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
here is my code for the request
$json = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=Einsteinufer63,10587,Berlin&key=AIzaSyDBA9EWB_zNWC6XjDu9mGyIuuV6QSL_ABM');
var_dump($json);
Here is the modified code i used urlencode() function for address
because if in case you are having space or some special characters in address then google api wont works by the above way
<?php
$json = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='.urlencode("Einsteinufer63,10587,Berlin").'&key=AIzaSyDBA9EWB_zNWC6XjDu9mGyIuuV6QSL_ABM');
var_dump($json);
?>
I've been using the following code to scrape keywords from Google:
$data=file_get_contents('http://clients1.google.com/complete/search?hl=en&gl=us&q='.$keyword);
However, my script has suggest started showing these errors:
Warning: file_get_contents(http://clients1.google.com/complete/search?hl=en&gl=us&q=money) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /home/username/public_html/keywords.php on line 10
I'm guessing this is being caused by Google changing the link? Does anyone know what the new link would be or what I need to change in my code?
Try this:
$url = 'http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl=en-US&q=';
$data=file_get_contents($url . urlencode( $keyword ) );
Hope it helps.
I'm using the following line with to get the page content:
$handle = file_get_contents(
"http://www.mywebsite.com/index.php?show=users&action=msg§ion=send",
NULL,
NULL,
1000,
19000);
And then, I'm getting the following message:
Warning:
file_get_contents(http://www.mywebsite.com/index.php?show=users&action=msg §ion=send):
failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
(Please take a note at the bolded part).
What happened to it? Why does it changes the url param?
I don't think PHP is changing querystring parameters.
If you are reading that message in the browser, it should be just a matter of how the output is HTML formatted. So, the 403 error you are getting it should not be related to some unwanted url transformation.