Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter adamwulf

    (@adamwulf)

    Not sure if this will help in the long run, but I’ve switched to using the following URL instead:

    https://public-api.wordpress.com/rest/v1/sites/54142117/posts?pretty=1&type=page

    This uses the blog ID instead of the domain. not sure if that will change anything. Either way the original URL should have worked.

    thoughts?

    Thread Starter adamwulf

    (@adamwulf)

    and to answer my own question: yes! it does seem to work 🙂

    script I used:

    if(isset($_REQUEST["tweet_load"])){
    
    	$dir_path = "/path/to/tweet/js/file/data/";
    
    	$haveCount = 0;
    	$addCount = 0;
    
    	if (is_dir($dir_path)) {
    	    if ($dir_handler = opendir($dir_path)) {
    	        while (($file = readdir($dir_handler)) !== false) {
    	        	if(strpos($file, ".js") > 0){
    
    	        		echo "loading " . $dir_path . $file . "<br>";
    
    					$contents = file_get_contents($dir_path . $file);
    					$contents = substr($contents, strpos($contents, "["));
    					$contents = "{ \"json\" : $contents }";
    					$json = json_decode($contents);
    
    					foreach($json->json as $twt){
    						$t = new AKTT_Tweet($twt);
    						if (!$t->exists_by_guid()) {
    							$t->add();
    							echo "adding " . $t->id() . "<br>";
    							$addCount++;
    						}else{
    							echo "passing " . $t->id() . "<br>";
    							$haveCount ++;
    						}
    					}
    	        	}
    	        }
    	        closedir($dir_handler);
    	    }
    	}
    
    	echo "adding: $addCount<br>";
    	echo "have: $haveCount<br>";
    
    exit;
Viewing 2 replies - 1 through 2 (of 2 total)