A
A
AdaSchwartz2017-09-09 13:19:01
PHP
AdaSchwartz, 2017-09-09 13:19:01

What is wrong with (file_get_contents)?

Gives an error: "file_get_contents(): Unable to get input stream for connection"

$token=$this->edit->text; 
$id=$this->textArea->text; 
STR_replace('http://vk.com/', '', $id); 
$this->textArea->text=$id; 
$this->textArea3->text.='Очистили список ссылок от: "http://vk.com/"'; 
STR_replace('public', '', $id); 
$this->textArea3->text.='Очистили список ссылок от: "public"'; 
STR_replace('club', '', $id); 
$this->textArea->text=$id; 
$this->textArea3->text.='Очистили список ссылок от: "club"'; 
$array = json_decode($h,true); 
$links = array($this->textArea->text); 
foreach ( $links as $links ) { 
$h = file_get_contents("https://api.vk.com/method=utils.resolveScreenName&screen_name=$links&acces_token=$token&v=5.62"); 
$array = json_decode($h,true); 
$p.=$array['response']['object_id'];

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2017-09-09
@Stalker_RED

Try to run this code

$w = stream_get_wrappers();
echo 'openssl: ',  extension_loaded  ('openssl') ? 'yes':'no', "\n";
echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
echo 'wrappers: ', var_export($w);

The output should be something like this:
openssl: yes
http wrapper: yes
https wrapper: yes
wrappers: array(11) {
  [...]
}
So you will know what exactly it lacks to process this request.
© https://stackoverflow.com/a/1975949

U
userfordownload, 2017-09-15
@userfordownload

is wrong here:
necessary

$request_params = array(
           'screen_name'=> $links,
           'access_token' => $token
        );
$get_params = http_build_query($request_params);
$h = json_decode(file_get_contents('https://api.vk.com/method/utils.resolveScreenName?' . $get_params ));

error in "=" sign
m/method = utils.resolv

but you must
m/method ? utils.resolv

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question